asp.net - How to data bind a CheckBoxList on page load

DataBind CheckBoxList on page load
ASP.NET CheckBoxList help user to select multiple items from a list. It is a very useful control in .net. this example present an important facility of CheckBoxList. we can data bind CheckBoxList in various way. we also can data bind CheckBoxList with many types of data sources. here we data bind CheckBoxList on page load event. When the page load in a browser then the CheckBoxList bind with data. In this example we choose a string array type data source to bind with CheckBoxList.
CheckBoxListDataBind.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        string[] controls = { "HyperLink", "ImageMap", "Panel", "Table", "XML" };
        CheckBoxList1.DataSource = controls;
        CheckBoxList1.DataBind();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to data bind CheckBoxList on page load</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Red">CheckBoxList: DataBind</h2>
        <asp:Label 
             ID="Label1"
             runat="server"
             Font-Bold="true"
             ForeColor="Green"
             Text="asp.net controls"
             >
        </asp:Label>
        <asp:CheckBoxList 
             ID="CheckBoxList1"
             runat="server"
             BorderColor="SeaGreen"
             BorderWidth="2"
             >
        </asp:CheckBoxList>
    </div>
    </form>
</body>
</html>
More asp.net examples