In
this article I am going to explain how to add items to checkboxlist code behind
in asp.net
HTML Markup:
<fieldset
style="width:400px">
<legend>Add items to checkboxlist </legend>
<asp:CheckBoxList ID="chboption" runat="server"></asp:CheckBoxList>
<asp:TextBox ID="txtoption" runat="server"></asp:TextBox><asp:Button ID="btnoption" runat="server" Text="btnsubmit" OnClick="btnoption_Click" />
</fieldset>
Add items to
checkboxlist
C#
Code:
protected void btnoption_Click(object sender, EventArgs e)
{
chboption.Items.Add(new ListItem(txtoption.Text));
}
VB.net
Code:
Protected Sub
btnoption_Click(sender As Object, e As EventArgs) Handles btnoption.Click
chboption.Items.Add(New ListItem(txtoption.Text))
End Sub
0 Comments