Speed up development with full-stack environments for every branch.

Learn More

ASP.net How to use Checkboxlist

13025 Runs 93087 Views 29558 Copies
Saved

Saved

invincibleideas 20

invincibleideas
published 4 years ago

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ASP.net How to use Checkbox list control</title>
    <style type="text/css">     
     div
     {
         margin:5px;
     }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div>
        <div style="width:400px; float:left;">
        <fieldset>
            <h3>How to use Checkbox list control</h3>
            <div>
            <asp:CheckBoxList ID="chklstStates" runat="server">
                <asp:ListItem Text="Alabama" Value="Alabama"></asp:ListItem>
                <asp:ListItem Text="Alaska" Value="Alaska"></asp:ListItem>
                <asp:ListItem Text="Arizona" Value="Arizona"></asp:ListItem>
                <asp:ListItem Text="Arkansas" Value="Arkansas"></asp:ListItem>
                <asp:ListItem Text="California" Value="California"></asp:ListItem>
                <asp:ListItem Text="Connecticut" Value="Connecticut"></asp:ListItem>
                <asp:ListItem Text="Florida" Value="Florida"></asp:ListItem>
                <asp:ListItem Text="Delaware" Value="Delaware"></asp:ListItem>
                <asp:ListItem Text="Hawaii" Value="Hawaii"></asp:ListItem>
                <asp:ListItem Text="Kentucky" Value="Kentucky"></asp:ListItem>
                <asp:ListItem Text="Maryland" Value="Maryland"></asp:ListItem>
                <asp:ListItem Text="New Jersey" Value="New Jersey"></asp:ListItem>
                <asp:ListItem Text="New York" Value="New York"></asp:ListItem>
            </asp:CheckBoxList>
            </div>
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
        </fieldset>
        </div>
        <div style="width:200px; float:left;">
         <fieldset>
            <h3>Selected States:</h3>
            <div>
                <asp:Label ID="lblStates" runat="server"></asp:Label>
            </div>
        </fieldset>
        </div>
    </div>
    </form>
</body>
</html>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).