Results 1 to 2 of 2

Thread: drop down list add

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2004
    Location
    Orlando
    Posts
    30

    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 *

  2. #2
    Member EricDalnas's Avatar
    Join Date
    Sep 2004
    Location
    Rhode Island
    Posts
    51
    Try

    lstAircraft.Items.Insert(0,"SELECT ALL")

    instead of

    lstAircraft.Items.Add("SELECT ALL")
    Maybe if you'd stop breathing and die for a change I wouldn't be so pissed off all the time.

    www.mredkj.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width