S
scartin
I'm fairly new to working with ASP web controls, and am running into
what seems to be a ridiculous problem that I'm hoping will be a breeze
for an experienced ASP developer.
I have a GridView and a FormView on the same page, where the GridView
is visible at page load, and the FormView is set to Edit mode by
default, but is hidden on the page. I have the Select link enabled on
my GridView, and I use the SelectedIndexChanged event to hide the
GridView, update the SelectCommand on my datasource with the
SelectedIndex, and finally show the FormView. This all works
beautifully, and I get my FormView populated with the data from the
selected Index shown on the page.
The code to handle this is fairly simple, and looks like the following:
(with the bulk of the query removed for readability)
what seems to be a ridiculous problem that I'm hoping will be a breeze
for an experienced ASP developer.
I have a GridView and a FormView on the same page, where the GridView
is visible at page load, and the FormView is set to Edit mode by
default, but is hidden on the page. I have the Select link enabled on
my GridView, and I use the SelectedIndexChanged event to hide the
GridView, update the SelectCommand on my datasource with the
SelectedIndex, and finally show the FormView. This all works
beautifully, and I get my FormView populated with the data from the
selected Index shown on the page.
The code to handle this is fairly simple, and looks like the following:
(with the bulk of the query removed for readability)
Code:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs
e)
{
GridView1.Visible = false;
FormView1.Visible = true;
FormView1.ChangeMode(FormViewMode.Edit);
dsPackageEdit.SelectCommand = "SELECT ... WHERE [ID] ="
+GridView1.SelectedDataKey.Values["ID"];
FormView1.DataBind();
}