为什么我的复选框选择不正确............. [英] Why my Checkbox select not true .............

查看:42
本文介绍了为什么我的复选框选择不正确.............的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach (GridViewRow gvRow in grdEmployee.Rows)
            {
                CheckBox chk = (CheckBox)gvRow.FindControl("chkEmp");

                if (chk != null && chk.Checked)
                {
                    DataRow row = dt.NewRow();
                    row["EmployeeName"] = gvRow.Cells[1].Text;
                    row["Designation"] = gvRow.Cells[2].Text;
                    dt.Rows.Add(row);
                   
                }


此复选框始终为false....请帮助解决此复选框.


This check box always false....pls help how to true the checkbox.

推荐答案

似乎posback在page_load事件中再次加载了数据-从而重置了复选框.
您能否调试一下,看看是否下一次page_load加载了gridview.

要停止此操作,请使用Page.IsPostback停止第二次(回发)加载.

欢呼声
It seems, the posback loads the data again in page_load event - thus reset the checkbox.
Could you debug and see, if next time page_load loads the gridview.

To stop this, use Page.IsPostback to stop the second time (postback) load.

cheers


此复选框始终为假
没有选中任何复选框,或者在事件触发前重新加载网格.

确保将网格的数据绑定代码放在Page IsPostback属性中,以避免在回发时重新绑定.
This check box always false
Either none of the checkboxes are checked OR you repload your grid before the event fires.

Make sure you put your databind code for the grid in a Page IsPostback property to avoid a rebind on postback.


这篇关于为什么我的复选框选择不正确.............的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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