Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 30-May-12 2:49am
Comments
Rajesh Kariyavula at 30-May-12 8:19am
   
May I know where you are setting the SelectedValue for the ListBox in the Page Load event.
Member 8956437 at 30-May-12 9:35am
   
im using the actual value from the listbox in some sql commands
Ed Nutting at 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 at 1-Jun-12 8:29am
   
mention autopostback= true ...
Kaushik Saha from Kolkata,India at 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)

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 30 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100