Maysam
Maysam

Reputation: 7367

ASP.NET: Adding check box to table cell

It's my table:

<asp:Table ID="Table1" runat="server">
    <asp:TableRow>
        <asp:TableCell>number</asp:TableCell>
        <asp:TableCell ID="webCell"></asp:TableCell>
    </asp:TableRow>
</asp:Table>

And it's my server-side code:

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

How can I add these check boxes to that cell?

Upvotes: 0

Views: 2510

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460340

WebCell is not runat=server, so you cannot reference it in codebehind, add it:

<asp:TableCell ID="webCell" runat="server"></asp:TableCell>

Upvotes: 1

Related Questions