protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox ch = (CheckBox)GridView1.FindControl("chkid");
if (ch.Checked)
{
Response.Write("ch= true");
Label1.Text = GridView1.Rows.ToString();
}
else
Response.Write("ch= false");
}
}
问问题
891 次
2 回答
2
更正这条线。
CheckBox ch = (CheckBox)GridView1.Rows[i].FindControl("chkid");
于 2013-07-13T06:58:01.600 回答
0
在使用复选框之前简单地做一个空检查
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox ch = (CheckBox)GridView1.FindControl("chkid");
if (ch != null)
{
if (ch.Checked)
{
Response.Write("ch= true");
Label1.Text = GridView1.Rows.ToString();
}
else
Response.Write("ch= false");
}
}
}
于 2013-07-13T06:52:49.557 回答