CheckedListBox and SqlDataSource not surviving postback - Long Story [modified]
-
Okay, here's my situation... I have three CheckBoxList. #1 is a list of four states. When a state is checked off, a sql query to retrieve a list of cities is generated in the control's SelectedIndexChanged method that is assigned to a SqlDataSource control's SelectCommand property. So far so good. However, control #2 is supposed to generate a query to fill a third CheckBoxList of stores in each city based on the cities the user checks. What happens is control #1's SelectedIndexChanged method fires on the post back when an item is checked in control #2. I tried handling this by checking the query generated by control #1 against the query in the SqlDataSource bound to control #2, however the datasource resets back to its original query created at design time. The EnableViewState property is set to true so I can't figure out why this is happening. I was also thinking that I could check the "object sender" parameter passed to the SelectedIndexChanged method of control #1 but that seems to indicate that control #1 is what is causing the post back rather than control #2. Another weird (to my Windows Forms based mind) is that when an item is selected in control #1, control #2's SelectedIndexChanged method isn't fired. Both control #1 and control #2 are set to AutoPostBack and are identical except for formatting stuff and the fact that they are bound to different SqlDataSources. control #3 doesn't post back, however just for the heck of it I set AutoPostBack to true. When an item is selected in control #3, control #1's SelectedIndexChanged method fires but again control #2's doesn't. Again, this is really weird because for the most part the controls are identical. Help, my brain is melting! :v) EDIT: I don't know if it makes a difference but control #1's values are hard coded so it isn't bound to a SqlDataSource -- modified at 12:29 Wednesday 8th August, 2007