在复选框上将AutoPostback设置为True时,GridView数据将重置 [英] GridView Data Resets When AutoPostback Set to True on Checkbox

查看:137
本文介绍了在复选框上将AutoPostback设置为True时,GridView数据将重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,从后面的代码中,我绑定到DataTable并以编程方式填充行数和单元格值.

当我单击将AutoPostBack设置为true的复选框时,gridview将重置.由于复选框的事件仅在其AutoPostBack设置为true时才执行,因此如何在gridview中维护这些值?将AutoPostBack设置为false时,是否可以触发复选框事件?

谢谢.

I have a gridview that, from within the code behind, I bind to a DataTable and programmatically populate number of rows and cell values.

When I click on a checkbox that has AutoPostBack set to true, the gridview resets. Since the events for the checkbox are executed only when its AutoPostBack is set to true, how do I maintain those values in the gridview? Can I get the checkbox events to fire when its AutoPostBack is set to false?

Thanks.

推荐答案

在页面加载事件中将gridbind函数置于非IsPostBack条件中,如下所示. if(!IsPostBack)
{
Bindgrid();
}
Place gridbind function in not IsPostBack condition in page load event as follow..
if(!IsPostBack)
{
Bindgrid();
}


这篇关于在复选框上将AutoPostback设置为True时,GridView数据将重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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