Could someone help me with the following issue.
I have a drop down list that gets its data from sql.
If I add the following code it works, but it adds the "Select Department" to the very end of the collection. I would like for it to be the first item in the dropdown list. If I move the "Select Department" before I call the databind method, it simply dissappears.
Thanks.....
If Page.IsPostBack = False Then
Try
myConnection.Open()
SweetDepts.DataSource = myCommand.ExecuteReader()
SweetDepts.DataBind()
SweetDepts.Items.Add("Select Department")
SweetDepts.Items.FindByText("Select Department").Value = "0"
SweetDepts.Items.FindByText("Select Department").Selected = True
myConnection.Close()
Catch e As Exception
SweetDepts.Items.Add("Departments Not Loaded")
SweetDepts.Items.FindByText("Departments Not Loaded").Value = 0
SweetDepts.Items.FindByText("Departments Not Loaded").Selected = True
End Try
End If
I have a drop down list that gets its data from sql.
If I add the following code it works, but it adds the "Select Department" to the very end of the collection. I would like for it to be the first item in the dropdown list. If I move the "Select Department" before I call the databind method, it simply dissappears.
Thanks.....
If Page.IsPostBack = False Then
Try
myConnection.Open()
SweetDepts.DataSource = myCommand.ExecuteReader()
SweetDepts.DataBind()
SweetDepts.Items.Add("Select Department")
SweetDepts.Items.FindByText("Select Department").Value = "0"
SweetDepts.Items.FindByText("Select Department").Selected = True
myConnection.Close()
Catch e As Exception
SweetDepts.Items.Add("Departments Not Loaded")
SweetDepts.Items.FindByText("Departments Not Loaded").Value = 0
SweetDepts.Items.FindByText("Departments Not Loaded").Selected = True
End Try
End If