Click here to Skip to main content
15,896,539 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to fetch value in label on web page.Values selected in the dropdwonlist.And Label are automatic create one bye one according to value.
Posted
Comments
DamithSL 5-May-14 4:07am    
tag the question with project type like winform, asp.net WPF...
update the question with the code what you already tried.
Explain where you stuck or having problems.
What is the problem here?

1 solution

Study the example and adapt:
the aspx page:
XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default32.aspx.cs" Inherits="Default32" %>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:DropDownList id="drop1" runat="server"
            onselectedindexchanged="drop1_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem Value="value1">Item 1</asp:ListItem>
            <asp:ListItem Value="value2">Item 2</asp:ListItem>
            <asp:ListItem Value="value3">Item 3</asp:ListItem>
            <asp:ListItem Value="value4">Item 5</asp:ListItem>
            <asp:ListItem Value="value5">Item 6</asp:ListItem>
    </asp:DropDownList>
        <div id="myDiv" runat="server">
        </div>
    </div>
    </form>
</body>
</html>

the code behind:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default32 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void drop1_SelectedIndexChanged(object sender, EventArgs e)
    {
        myDiv.InnerHtml = myDiv.InnerHtml + "<br />" + drop1.SelectedValue;
    }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900