I have a GridView control connected to a data source that allows row editing. I use the standard edit / save / delete buttons that point to the Refresh, Undo, and Edit GridView commands.
I would like to add an additional "Next" button to the line with the save / cancel button. This will work just like the save button, but it will also add an extra line to the grid and put that line into edit mode. To do this, I added code to the UpdatedGridView event , which adds a new record to db, restores the grid, and installs editindex. This seems to work, but the grid does not actually return in edit mode. I deleted the new recording code and simply left the statement to install editindex, but the grid still would not remain in edit mode.
Is it possible to force the grid to remain in edit mode in this scenario? It seems that if you do not set the cancel property GridViewUpdatedEventArgs, the grid will switch to view mode. I do not want to set the cancel property in this case, because I want the GridView to run my data source object to save the record.
If this does not work, it seems that I will need to update the update normally, return to the client, and then send another server request to add the record. I would prefer not to do it this way, I would like to perform the necessary operations in the context of one tour.
Here is what the code looks like (simplified):
protected void Button1_Click(object sender, EventArgs e)
{
this.sampleDataSource.Insert();
this.sampleGridView.DataBind();
this.sampleGridView.EditIndex = this.sampleGridView.Rows.Count - 1;
}
protected void sampleGridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
this.sampleDataSource.Insert();
this.sampleGridView.DataBind();
this.sampleGridView.EditIndex = this.sampleGridView.Rows.Count - 1;
}
source
share