Click here to Skip to main content
11,922,641 members (56,748 online)
Rate this:
Please Sign up or sign in to vote.

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
Posted 30-May-12 2:49am
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.

deepureddy18 1-Jun-12 8:29am
mention autopostback= true ...
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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151125.1 | Last Updated 30 May 2012
Copyright © CodeProject, 1999-2015
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