How to use CheckBoxList in asp.net c#

CheckBoxList control example
CheckBoxList.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e) {

        Label1.Text = "Your selected item(s)....<br />";
        foreach(ListItem li in CheckBoxList1.Items){
            if (li.Selected == true) {
                Label1.Text += li.Text + "<br />";
            }
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to use CheckBoxList control in asp.net</title>
</head>
<body style="padding:25px">
    <form id="form1" runat="server">
    <div>
        <h2 style="color:MidnightBlue; font-style:italic;">      
            How to use CheckBoxList
        </h2>      
        <hr width="450" align="left" color="Gainsboro" />
        <asp:Label
            ID="Label1"
            runat="server"
            Font-Bold="true"
            Font-Names="Comic Sans MS"
            ForeColor="Crimson"
            Font-Italic="true"
            Font-Size="X-Large"
            />
        <br /><br />
        <asp:Label 
            ID="Label2"
            runat="server" 
            Text="Select your favorites" 
            AssociatedControlID="CheckBoxList1"
            Font-Underline="true"
            Font-Bold="true"
            Font-Size="X-Large"
            />
        <asp:CheckBoxList 
            ID="CheckBoxList1"
            runat="server"
            Font-Italic="true"
            Font-Names="Courier New"
            Font-Size="X-Large"
            >
            <asp:ListItem>ColdFusion</asp:ListItem>
            <asp:ListItem>PHP</asp:ListItem>
            <asp:ListItem>JSP</asp:ListItem>
            <asp:ListItem>Asp.Net</asp:ListItem>
            <asp:ListItem>Flex</asp:ListItem>
        </asp:CheckBoxList>
        <br />
        <asp:Button 
            ID="Button1" 
            runat="server" 
            Text="Show Result" 
            OnClick="Button1_Click"
            Font-Bold="true"
            Font-Size="Large"
            ForeColor="Navy"
            Font-Names="Monaco"
            Height="45"
            Width="350"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples