首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

gridview checkbox 有关问题 急

2012-01-14 
gridview checkbox 问题 急!!!CheckBoxchecBox(CheckBox)this.GridView1.Rows[i].Cells[j].FindControl(

gridview checkbox 问题 急!!!

  CheckBox   checBox   =   (CheckBox)this.GridView1.Rows[i].Cells[j].FindControl( "chk "   +   (j   -   2));
                                if   (checBox.Checked   ==   true)
                                {
                                        strRequset   +=   "1 ";
                                }
                                else
                                {
                                        strRequset   +=   "0 ";
                                }

为什么   if   (checBox.Checked   ==   true)   会提示未将对象引用设置到对象的实例。我已经认真核对过FindControl( "chk "   +   (j   -   2))  
请问还有什么原因会产生上面的错误呢

[解决办法]
1,控件 "chk " + (j - 2)是否存在?
2,你是在什么事件里操作的?

可以参考
http://dotnet.aspx.cc/article/a8efc285-f0b1-4f8f-8e73-2b7d8724a47c/read.aspx
[解决办法]
是第一次就出错还是ij循环到某一个值时出错啊
[解决办法]
CheckBox checBox = (CheckBox)this.GridView1.Items[i].FindControl( " ");试试
[解决办法]
this.GridView1.Rows[i].Cells[j].FindControl()的问题吧!
可能么没找到CheckBox

热点排行