Drop down list is asp.net form
-
I have a drop down list in my asp.net form that I have populated from my database using datasource and databind. This bit is fine. Now I want the first option text and value to be blank. Can anyone help me??? Thanks
hi, Replace your SQL statement; Select '' As Code,'' As DescCode Union Select Code, DescCode From Table1 The idea is add one blank row to your sql statement. regards;
-
I have a drop down list in my asp.net form that I have populated from my database using datasource and databind. This bit is fine. Now I want the first option text and value to be blank. Can anyone help me??? Thanks
you can do it by adding new item to dropdownlist after binding it then swap between first items and last item because when u add new item automatically add at last index or u can select items in array form database and changing what do you want to change on it then make dropdownlist data source form array . 2'nd sol. I.N.M(InterNetMouse)
-
I have a drop down list in my asp.net form that I have populated from my database using datasource and databind. This bit is fine. Now I want the first option text and value to be blank. Can anyone help me??? Thanks
After DataBind() insert a new item like this: MyopDownList.Items.Insert(0,new ListItem("","")); This adds a new item at the first position.
-
After DataBind() insert a new item like this: MyopDownList.Items.Insert(0,new ListItem("","")); This adds a new item at the first position.
Thanks gninneh it's good :) I.N.M(InterNetMouse)
-
I have a drop down list in my asp.net form that I have populated from my database using datasource and databind. This bit is fine. Now I want the first option text and value to be blank. Can anyone help me??? Thanks
After you bind the data to the dropdownlist, you can add a new listitem and set the index to 0. This will store the blank row at the top of the list and even allow you to set it as selected by default. ------------------------------------- I have no prayer for that. - Stark, Farscape