在你的模版中给asp:CheckBox起个名字叫name="cb";在代码中
string[] s = Request.Params.GetValues("cb");
for( int i=0;s!= null&& i<s.Length;i++)
Response.Write( s[i] + "<br>" );
string[] s = Request.Params.GetValues("cb");
for( int i=0;s!= null&& i<s.Length;i++)
Response.Write( s[i] + "<br>" );
{
CheckBox mycheckbox=(CheckBox)(dgi.Cells[0].FindControl("check"));
if (mycheckbox.check=true)
.........
}
其中check是你的checkbox的名称,这段代码用来检查你的checkbox是否被选中。
不知道这段代码是不是对你有启发。
{
CheckBox cb = (CheckBox)(e.Item.Cells[2].Controls[0]); //0不行就试试1
if( cb.Checked )
{
// DoSomething
}
}
行 94: {
行 95: CheckBox mycheckbox=(CheckBox)(dgi.Cells[2].FindControl("checkadd"));
行 96: if (mycheckbox.Checked) // 出错 未将对象引用设置到对象的实例。
行 97: {
行 98: Label1.Text="true";