Search

Friday, September 27, 2013
0 comments

Example of Add item to DropdownList in ASP.NET

9:20 PMFriday, September 27, 2013
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        DropDownList1.Items.Add("Apple");
        DropDownList1.Items.Add("mango");
        DropDownList1.Items.Add("orange");
     
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label1.Text = "your selected item is <br/>" + DropDownList1.SelectedItem.Text;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server" Height="20px"
            onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="186px"
            AutoPostBack="True">
        </asp:DropDownList><br />
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    </div>
    </form>
</body>
</html>

Output
Example of Add item to DropdownList in ASP.NET

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top