Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi every body!
I want to load data into label on page from database. i use event SlectedIndexChange of Dropdownlist in code behind, but it doesn't work for my. Are there any body know? How i can do that?
Tell me, please.
Thanks everyone!
Posted
Comments
Anele Ngqandu 5-Aug-11 7:38am    
If you could update your question by submiting the code you have I think I might be able to help you.

Did you add AutoPostBack = "true" in Dropdownnlist?
 
Share this answer
 
Use Autopostback="true"
ASP.NET
<asp:dropdownlist id="DropDownList1" runat="server" onselectedindexchanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true" >


And you need to turn on the viewstate. EnableViewState="true"

Also make sure the event name is correct. It should be OnSelectedIndexChanged not SelectedIndexChanged. Also check the event name matching on both codebehind & ASPX
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

Also another issue & solution(Not sure your issue is same as this one)
Detect DropDownList SelectedIndexChanged on Page Load[^]

Gotcha I found that link
ASP.NET: Error: DropDownList OnSelectedIndexChanged Event Not Firing[^]
 
Share this answer
 
v2
Comments
thanhntt89 5-Aug-11 4:06am    
Ok thank for helping me. I've done it
You're going right. But the only thing you've missed off is setting
AutoPostBack=True
of the DropdownList.
 
Share this answer
 
Don't forget to set AutoPostback true of DropdownList. Always keep that in mind.
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 12-Aug-11 11:01am    
What's the matter with your '.' key. Did it get stuck again?
fjdiewornncalwe 16-Aug-11 14:22pm    
Again, you didn't bother to read the other answers first. Solution 1 already gave the answer.

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