Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have the code to auto select the first item in a listbox, and when i start the web page , the first item is selected, but the other code that i have after the selection has been made its not firing.
When i select the second item and then the first one again, everything works fine.


Best Regards
ThankYou
Posted
Comments
Rajesh Kariyavula 30-May-12 8:19am    
May I know where you are setting the SelectedValue for the ListBox in the Page Load event.
Member 8956437 30-May-12 9:35am    
im using the actual value from the listbox in some sql commands
Ed Nutting 30-May-12 14:20pm    
Sorry do you mean that when you auto-select the first item in your list you expect your (I assume you have from what you imply), your selection change event to be called? If so you are mistaken as to what you are doing. Selecting an item in server rendering code (in the Page_Load event) does not cause (and physically cannot cause) a post back and so not event gets fired - just think about the request lifecycle! Where as the user (you) selecting the first item (regardless of what was selected before) does cause a post back from client (you) to the server where your event is then fired. If you want to run code after auto-selecting the first item, you will have to call your method after selecting the item in the Page_Load event.

Ed
deepureddy18 1-Jun-12 8:29am    
mention autopostback= true ...
Kaushik Saha from Kolkata,India 10-Jul-12 10:30am    
If u clarify your problem with some code snippets

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