编辑GridView控件不工作后过滤 [英] Editing GridView Not Working After Filter
问题描述
我有一个动态模板gridview的。
I have a dynamically templated gridview.
它允许编辑,删除和插入新的数据到表中。
It allows editing, deleting, and inserting new data into the table.
我也实现了另一种功能,将允许过滤GridView的。
I also implement another function that will to allow filtering the gridview.
目前我能做的过滤非常好。然而,进入编辑模式时,在GridView以某种方式重新设置为状态之前过滤。
Currently I can do the filtering very well. However, when entering the editing mode, the gridview is somehow reset to "state before filtered".
例如:GridView的orginally有100行。过滤只有10行之后。进入编辑模式相比,将再次显示100行。
Ex: Gridview orginally has 100 rows. After filtered only 10 rows. Enter editing mode than it will display 100 rows again.
下面是我的,而GridView控件进入编辑模式的片段。
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;
}
任何帮助是AP preciated ...
Any help is appreciated...
推荐答案
删除调用的DataBind()
在 RowEditing
方法。
public void GridView_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView.EditIndex = e.NewEditIndex;
((TemplateField)GridView.Columns[1]).EditItemTemplate = null;
Session["SelecetedRowIndex"] = e.NewEditIndex;
}
通过调用的DataBind()
在这里你恢复电网到其原始数据源,从而失去你previously应用的过滤。
By calling DataBind()
here you're reverting the grid to its original data source, thereby losing the filtering you've previously applied.
修改
您是否尝试过重新应用过滤器的 RowEditing
方法之前结束?
Have you tried re-applying your filter before your RowEditing
method ends?
这篇关于编辑GridView控件不工作后过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!