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

Learn More

ASP.net How to use dropdownlist

21980 Runs 223811 Views 82519 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 Dropdown list</title>    
    <style type="text/css">        
        div
        {
            margin: 5px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <fieldset>
            <h3>How to use Dropdown list</h3>
            <div>
            <label>Gender:</label><br />
            <asp:DropDownList ID="ddlGender" runat="server" Width="200px">
                <asp:ListItem Text="Select Gender" Value="0"></asp:ListItem>
                <asp:ListItem Text="Male" Value="1"></asp:ListItem>
                <asp:ListItem Text="Female" Value="2"></asp:ListItem>
            </asp:DropDownList>
            </div>
            <div>
                <asp:Button ID="btnSubmit" runat="server" 
                    Text="Click to Retrieve Value" onclick="btnSubmit_Click" />            
            </div>
            <div>
                Selected Item Text: <asp:Label ID="lblSelectedText" runat="server"></asp:Label>
            </div>
            <div>
                Selected Item Value: <asp:Label ID="lblSelectedValue" runat="server"></asp:Label>
            </div>
        </fieldset>
    </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).