这是我的表:
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell>number</asp:TableCell>
<asp:TableCell ID="webCell"></asp:TableCell>
</asp:TableRow>
</asp:Table>
这是我的服务器端代码:
For i = 0 To IDsList.Length - 1
Dim chk As CheckBox = New CheckBox()
chk.ID = "webCatID" & Convert.ToString(i)
chk.Text = Convert.ToString(CatsName(i))
chk.BorderStyle = BorderStyle.None
chk.CssClass = "checkBox"
webCell.Controls.Add(chk) 'does not work, it does not webCell
Next
如何将这些复选框添加到该单元格?
答案 0 :(得分:1)
WebCell
不是runat=server
,因此您无法在代码隐藏中引用它,添加它:
<asp:TableCell ID="webCell" runat="server"></asp:TableCell>