日期:2014-05-20  浏览次数:20565 次

怎么判断复选框是否被选中
我用的是2005
TableRow   tr   =   new   TableRow();
  TableCell   tasktc1   =   new   TableCell();
                                CheckBox   chk   =   new   CheckBox();
                                chk.Text   =   "测试记录编号: "   +   testRed[ "id "].ToString();
                                tasktc1.Controls.Add(chk);
tr.Cells.Add(tasktc1);
testTab.Rows.Add(tr);
怎么判断这个复选框是否被选中!
谢谢各位~本人处在学习阶段!请大家帮帮忙

------解决方案--------------------
给你写了个例子:

<asp:Table ID= "testTab " runat= "server "> </asp:Table>
<asp:Button ID= "Button1 " runat= "server " Text= "Button " OnClick= "Button1_Click " />


CheckBox chk;

protected void Page_Load(object sender, EventArgs e)
{
TableRow tr = new TableRow();
TableCell tasktc1 = new TableCell();
chk = new CheckBox();
chk.ID = "chk_12345678 ";
chk.Text = "测试记录编号: " + "12345678 ";
tasktc1.Controls.Add(chk);
tr.Cells.Add(tasktc1);
testTab.Rows.Add(tr);
this.SmartNavigation = true;
}

protected void Button1_Click(object sender, EventArgs e)
{
this.Button1.Text = "选择值: "+ chk.Checked.ToString();
}