Link to home
Start Free TrialLog in
Avatar of tia_kamakshi
tia_kamakshiFlag for United Arab Emirates

asked on

Capture dropdownlist value changed

Hi Experts,

I am working on ASP.NET 2.0 using C#

I wanted to update label whenever my value is dropdown list changed.

I have written code which is not working.

Please guide me with the issue

Thanks

ASPX CODE
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem>A</asp:ListItem>
        <asp:ListItem>B</asp:ListItem>
        <asp:ListItem>C</asp:ListItem>
        <asp:ListItem>D</asp:ListItem>
        <asp:ListItem>E</asp:ListItem>
</asp:DropDownList>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Open in new window


CODE BEHIND
protected void Page_Load(object sender, EventArgs e)
{

}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
	string str = DropDownList1.SelectedValue;

	Label1.Text = str;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tia_kamakshi

ASKER

Thanks