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

Learn More

ASP.net How to use dropdownlist

21980 Runs 223811 Views 82519 Copies


invincibleideas 20

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">        
            margin: 5px;
    <form id="form1" runat="server">
            <h3>How to use Dropdown list</h3>
            <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:Button ID="btnSubmit" runat="server" 
                    Text="Click to Retrieve Value" onclick="btnSubmit_Click" />            
                Selected Item Text: <asp:Label ID="lblSelectedText" runat="server"></asp:Label>
                Selected Item Value: <asp:Label ID="lblSelectedValue" runat="server"></asp:Label>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).