Hi, on my website i have gridview with select button dispalying a list of persons connected with objectdatasource. When I select person in gridview i want to fill form under gridview. Here is gridviews databound and selectedindexchanging methods:
protected void grdAnotatorList_DataBound(object sender, EventArgs e)
{
if (grdAnotatorList.Rows.Count > 0)
{
int idAnotator = Convert.ToInt32(grdAnotatorList.SelectedValue);
FillAnotatorDetail(GetAnotatorDetail(idAnotator));
}
else grdAnotatorList.SelectedIndex = -1;
}
protected void grdAnotatorList_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
int idAnotator = Convert.ToInt32(e.NewSelectedIndex);
FillAnotatorDetail(AnotatorManager.Instance.GetAnotatorDetail(idAnotator));
}
I fill the form in databound event because i want to use datakeyname of the corresponding row when it is really databound to gridview and i also want to fill the form when the user visits this website for the first time. Similar code i have in selectedindexchanging event because i want to refill the form when user clicks on another row in gridview. But i have in my form another buttons for example i want to move one district from first listbox to second listbox and when i click them databound event of gridview is raised and everything what user changed in form is replaced because databound event was raised. My website looks like this: http://www.freeimagehosting.net/image.php?819c1c553c.jpg
So my question is, in which event can i put the code from databound event or is there some general pattern for similar scenarios? Thanks for your answers.