编辑点击时丢失gridview数据 [英] Losing gridview data on edit click

查看:104
本文介绍了编辑点击时丢失gridview数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个奇怪的问题。

我在Updatepanel内的Usercontrol中使用asp.net GridView并使用标准的CRUD操作。

当我点击编辑以编辑一行时,gridview数据源变为空

<前一个=C#> 如果( !IsPostBack)
{
FillGrid();

}



因为它没有进入FillGrid()的那一行;

如果这个问题消失了删除回发检查。但是当我尝试更新行时,它不会进入row_updating或除page_load之外的任何其他事件。

根据我的理解它失去了与EditItemTempelate /
的所有事件绑定
请帮忙。我很难坚持这个问题



我尝试过的事情:



1 - 启用/禁用ViewState

2 - 为Update Click绑定单独的事件。

在row_editing方法中绑定点击事件

a一堆其他解决方案

解决方案

试试这个

 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
FillGrid();
}


Hi,
I have a strange problem.
I'm using asp.net GridView in a Usercontrol inside Updatepanel with standard CRUD operations.
When I click on Edit to Edit a row, The gridview datasource becomes null

if (!IsPostBack)
   {
     FillGrid();

   }


because it doesn't go into that line to FillGrid();
This problem vanished if remove the postback check. but then when I tried to Update the Row, it doesn't go into row_updating or any other event apart from page_load.
According to my understanding It loses all its event binding with EditItemTempelate/
Please help. I'm badly stuck on this problem

What I have tried:

1-Enable/Disabled ViewState
2-Binding separate events for Update Click.
3-Binding click event in row_editing method
a bunch of other solutions

解决方案

try this

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
    GridView1.EditIndex = e.NewEditIndex;
    FillGrid();
}


这篇关于编辑点击时丢失gridview数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆