<%@ Page Language="VB" %>

<script runat="server">
    Protected Sub Button1_Click(ByVal sender As Object, _
       ByVal e As System.EventArgs)

        Label1.Text = "Wybrałeś:<br>"
        For Each li As ListItem In CheckBoxList1.Items
            If li.Selected = True Then
                Label1.Text += li.Text & "<br>"
            End If
        Next
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Kontrolka CheckBoxList</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Zatwierdź wybór" 
         OnClick="Button1_Click" /><br /><br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" 
         DataSourceID="SqlDataSource1" DataTextField="CompanyName" 
         RepeatColumns="3" BorderColor="Black" 
         BorderStyle="Solid" BorderWidth="1px">
        </asp:CheckBoxList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         SelectCommand="SELECT [CompanyName] FROM [Customers]"
            ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>">
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>
