Create Checkbox using C#.Net dynamically

This is how you can create Checkbox dynamically in run time in C#.Net.

aspx Code:

<asp:Panel ID="PnlControl" runat="server"> </asp:Panel>

C# Code:

for (int i = 0; i < 10; i++)
 {
     CheckBox chkList1;
     chkList1 = new CheckBox();
     chkList1.Text = "CheckBox " + i.ToString();
     chkList1.ID = "Chk" + i.ToString();
     chkList1.Font.Name = "Verdana";
     chkList1.Font.Size = 9;
     PnlControl.Controls.Add(chkList1);
     PnlControl.Controls.Add(new LiteralControl("</br>
"));
 }


Accordingly you can modify this code.

 
Designed and Maintained by