FormView ChangeMode Question
I have a formview that is bound to an object data source. Depending on whether or not a database row is found I want to change the mode from Read Only to either Edit or Insert. In order to do this I have the following code:
protected void FormView1_DataBound(object sender, EventArgs e)
{
if (FormView1.DataItemCount == 0)
{
FormView1.ChangeMode(FormViewMode.Insert);
}
else
{
FormView1.ChangeMode(FormViewMode.Edit);
}
}
The problem that I am facing is that when a row exists in the database, changing the mode to Edit causes my object data source Selecting event to run a second time. This means that the same row that was just read will be read a second time.
Is there anyway to prevent a re read of the database while still binding to the FormView?
Thanks
|