在网格视图中获取复选框的值。 [英] To get the value of check box in grid view.

查看:72
本文介绍了在网格视图中获取复选框的值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CheckBox chk = grdAssign.Rows[i].Cells[0].FindControl("chkStatus") as CheckBox;
if (chk.Checked==true)
{
    clsProjectBO objProject = new clsProjectBO();
    objProject.Project_Name = grdAssign.Rows[i].Cells[1].Text;
}



我得到了检查obx,但是检查值总是假的,所以给我建议。


I got the check obx but it get checked value always false so give me suggestion.

推荐答案

我怀疑您在页面加载事件时绑定数据。如果是这样,请将相关代码放入



I suspect that you are binding the data at the time of page load event. If this is so, put the relevant code inside

if(!IsPostBack) 
{
   //code goes here
}





对你有帮助。



问候...... :)



that would be helpful for you.

Regards... :)


这意味着你的GridView在每次回发中再次重新绑定n。在Page_Load事件下使用 if(!IsPostBack){....} 代码块来绑定GridView。试试这个:

This means that your GridView is rebinding again n again in every postback. Use if(!IsPostBack){....} code block under Page_Load event to bind your GridView. Try this:
protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack) 
    {
       //Bind your gridview here
    }
}


这篇关于在网格视图中获取复选框的值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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