[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 702
  • Last Modified:

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

0
tia_kamakshi
Asked:
tia_kamakshi
1 Solution
 
informaniacCommented:
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostback="true">
0
 
tia_kamakshiAuthor Commented:
Thanks
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now