|
-
Oct 15th, 2004, 02:35 PM
#1
Thread Starter
Junior Member
drop down list add
I have a drop down list that gets populated by a database. I would like for the first thing to show in the dropdown list to be ((SELECT ALL))
I have some code but it adds ((SELECT ALL )) at the bottom of my dropdownlist and I want it at the beginning.
<my code>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
lstAircraft.DataSource = GetAircraft() 'this function will load the Tail Numbers
lstAircraft.DataValueField = "ID"
lstAircraft.DataTextField = "TailNumber"
lstAircraft.DataBind()
lstAircraft.Items.Add("SELECT ALL")
End If
End Sub
Function GetAircraft() As System.Data.DataSet
'this function will load the Tail Numbers
Dim connectionString As String = "myconnection"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [Aircraft].[TailNumber], [Aircraft].[ID] FROM [Aircraft] ORDER BY [Aircraft].[TailNumber] "
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Thanks
Rock *
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|