I have a dynamically templated gridview.
It allows editing, deleting, and inserting new data into the table.
I also implement another function that will to allow filtering the gridview.
Currently I can do the filtering very well. However, when entering the editing mode, the gridview is somehow reset to “state before filtered”.
Ex: Gridview orginally has 100 rows. After filtered only 10 rows. Enter editing mode than it will display 100 rows again.
Here is the snippet while my gridview enter the editing mode.
public void GridView_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView.EditIndex = e.NewEditIndex;
((TemplateField)GridView.Columns[1]).EditItemTemplate = null;
GridView.DataBind();
Session["SelecetedRowIndex"] = e.NewEditIndex;
}
Any help is appreciated…
Remove the call to
DataBind()in yourRowEditingmethod.By calling
DataBind()here you’re reverting the grid to its original data source, thereby losing the filtering you’ve previously applied.EDIT
Have you tried re-applying your filter before your
RowEditingmethod ends?