2013-02-17 79 views
0

這是我的表:ASP.NET:添加複選框,以表格單元格

<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 

我怎樣才能增加這些複選框到該小區?

回答

1

WebCellrunat=server,所以你不能引用它在代碼隱藏,添加:

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

我以爲它知道它!謝謝。 – Maysam 2013-02-17 20:54:41