papa_k Posted November 25, 2003 Posted November 25, 2003 Basically I want to be able to set the default value of a combo box. I have tried... comboBox1.SelectedItem.Text = "Turnip" which does indeed set the value, but it also creates the value within the dropdown box. The problem is that i have already created the combo box values from a table within a database. When i use the above method, i get a duplicate value in the list, which is very untidy. how do i simply place the text within the dropdown? with vb6 i would use.. comboBox1 = "Turnip" this would set the default value to "Turnip" but would not create it within the list... Quote without time nothing ever ends
*Experts* Volte Posted November 25, 2003 *Experts* Posted November 25, 2003 How aboutcomboBox1.SelectedIndex = comboBox1.FindString("Turnip") Quote
papa_k Posted November 25, 2003 Author Posted November 25, 2003 This does not work. I have had a look on the web and i think that the findstring is used for a list box. Sorry, i am using a dropdownbox, which does not support the find string. Papa Quote without time nothing ever ends
Administrators PlausiblyDamp Posted November 25, 2003 Administrators Posted November 25, 2003 After you have done the .DataBind try DropDownList1.Items.FindByText("Turnip").Selected = True Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
papa_k Posted November 25, 2003 Author Posted November 25, 2003 excellent, it works! Thanks very much. Papa Quote without time nothing ever ends
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.