How to ADD New Item to CheckBoxList Programmatically in ASP.Net

In this ASP.Net Tutorials we will learn, How to ADD New Item in CheckBoxList Programmatically in ASP.Net with C# with an Example.

STEP 1 – Design the ASP.Net web form with a TextBox Control, a Button Control, a CheckBoxList Control and one Label Control look like :

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;ADD
New Item – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”ADD Item” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
</asp:CheckBoxList>
<asp:Label ID=”Label1″ runat=”server”></asp:Label></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

The ASP.Net CheckboxList Control ADD New Item Example output is :

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

STEP 2 – write the below code on Button Click event of ASP.Net code page:

protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList1.Items.Add(TextBox1.Text);
Label1.Text = “Item Added Successfully !”;
}

The ASP.Net CheckboxList Control ADD New Item Example output is :

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

The ASP.Net CheckboxList Control ADD New Item Example output is :

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

I hope this Add new item to CheckboxList Control programmaticaly in ASP.Net with C# tutorial will help you…….

Leave a Reply

Your email address will not be published. Required fields are marked *

5 + 9 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">