|
|||||||
| .NET Discussion and technical support for, building, using and deploying .NET sites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Drop down list option disappears
If I write
Code:
<asp:ListItem Value="0">--Select Category --</asp:ListItem> To populate the drop-down list I am doing something like this to get the list items from a database: Code:
conn.Open()
reader = categoryComm.ExecuteReader()
categoryList.DataSource = reader
categoryList.DataValueField = "CategoryID"
categoryList.DataTextField = "Category"
categoryList.DataBind()
reader.Close()
How can I get the --Select Category-- option to stay there? Thanks for any help. |
|
#2
|
||||
|
||||
|
You can do this 1 of two ways. I prefer this first method
1. Code:
conn.Open()
reader = categoryComm.ExecuteReader()
With categoryList
.DataSource = reader
.DataValueField = "CategoryID"
.DataTextField = "Category"
.DataBind()
.Items.Insert(0, New ListItem("--Select Category--", ""))
End With
reader.Close()
You should be able to set this property of the drop down list Code:
AppendDataBoundItems="true" |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|