Hi
I have a dropdown list (ddlStep1) on a form which is populated from a datareader. However I would like the first entry on the dropdown list to say "Please Select" however I am having trouble adding this. The dropdown list does a PostBack which I need, however it will not postback the first value if the first value was from the datareader. So basically I need the first value to say "Please Select" and so the datareader starts from position 2 in the list allowing it to be posted back.
My code is as follows:
Dim Conn As New SqlConnection(ConfigurationSettings.AppSettings("connBSS")
Dim strSQL As String = "SELECT * FROM Issues WHERE Iss_IsID Is NULL ORDER BY IsTeenDesc"
Dim Cmd As New SqlCommand(strSQL, Conn)
Conn.Open()
ddlStep1.DataSource = Cmd.ExecuteReader
ddlStep1.DataBind()
Conn.Close()
-------
<aspropDownList id="ddlStep1" DataTextField="IsTeendesc" DataValueField="IsID" runat="server" AutoPostBack="True"></aspropDownList>
I thought I could do something like:
ddlStep1.items.insert()
or
ddlStep1.Items.Add()
But this did not work or maybe I am putting it in the wrong section of code, im not sure. Any help would be greatly appreciated.
Thanks in advance
I have a dropdown list (ddlStep1) on a form which is populated from a datareader. However I would like the first entry on the dropdown list to say "Please Select" however I am having trouble adding this. The dropdown list does a PostBack which I need, however it will not postback the first value if the first value was from the datareader. So basically I need the first value to say "Please Select" and so the datareader starts from position 2 in the list allowing it to be posted back.
My code is as follows:
Dim Conn As New SqlConnection(ConfigurationSettings.AppSettings("connBSS")
Dim strSQL As String = "SELECT * FROM Issues WHERE Iss_IsID Is NULL ORDER BY IsTeenDesc"
Dim Cmd As New SqlCommand(strSQL, Conn)
Conn.Open()
ddlStep1.DataSource = Cmd.ExecuteReader
ddlStep1.DataBind()
Conn.Close()
-------
<aspropDownList id="ddlStep1" DataTextField="IsTeendesc" DataValueField="IsID" runat="server" AutoPostBack="True"></aspropDownList>
I thought I could do something like:
ddlStep1.items.insert()
or
ddlStep1.Items.Add()
But this did not work or maybe I am putting it in the wrong section of code, im not sure. Any help would be greatly appreciated.
Thanks in advance