Showing CheckBox as a list

By using these line of code we can show checkbox as a list

  <div style="border: thin solid; overflow: auto; width: 120px; height: 100px">
        <asp:CheckBoxList ID="CheckBoxList1" runat="server">
        <asp:ListItem Value="1">Noida</asp:ListItem>       
        <asp:ListItem Value="2">Delhi</asp:ListItem>       
        <asp:ListItem Value="3">Gurgaon</asp:ListItem>       
        <asp:ListItem Value="4">Chandigarh</asp:ListItem>       
        </asp:CheckBoxList>
    </div>

ChkList.PNG

If u want to perform some operation on this list u can do like as...

foreach (ListItem lst in CheckBoxList1.Items)
{
    if (lst.Selected)
   {
        Response.Write("Select CheckBox Text=" + lst.Text + " & Id=" + lst.Value + "<br>");
   }
}

Ebook Download
View all
Learn
View all