Jay1b Posted March 29, 2006 Posted March 29, 2006 I'm using dropdownlists for the user to select an item which is then saved into the database. I'm sure this WAS working when i originally tested it, now i've come back to it (was using the frame to set up test data for a later frame) and its not working. (It just selects the first item). I've even tried the below, which isnt working either. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Label11.Text = ddownRoles.SelectedIndex.ToString 'also tried selectedvalue, which as i'm sure you know displays the samething End Sub I'm using .Net 2005, i've checked that the 'EnableViewState' is set to true. I'm guessing this has something to do with the button doing a postback. After the label has been changed (to show the first item, not the selected one), the dropdownlist shows the first item again. Does anybody know what i've done to display the viewstate memory? Thanks. Quote
Administrators PlausiblyDamp Posted March 29, 2006 Administrators Posted March 29, 2006 How are you populating the list? If you are manually loading data or databinding in the page_load then this will lose the selection, make sure you only populate the list on the initial page_load and not for any post back events. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jay1b Posted March 29, 2006 Author Posted March 29, 2006 I'm calling the procedure to populate the in the page_load, but its wrapped in a "if not ispostback". I think i've solved it by setting the dropdownlists to autopostback, but i'm not sure if thats the 'best' way to do this. Thanks for the reply though :) Quote
Jay1b Posted March 29, 2006 Author Posted March 29, 2006 No. Nothing could modify the dropdown (in most screens). Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.