View Single Post
  #1 (permalink)  
Old December 21st, 2005, 05:33 AM
testsubject testsubject is offline
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Binding a DataReader To A List Box

Hi folks,

I have a little problem with a datareader and a listbox.

Please see code below

Code:
        If Not Page.IsPostBack Then
            Dim cmdWardList As New Odbc.OdbcCommand("SELECT WARDCODE, WARDNAME FROM ASSETDDH.WARDS5 ORDER BY WARDNAME", cnBarwickPas)
            cnBarwickPas.Open()
            Dim drWardList As Odbc.OdbcDataReader
            drWardList = cmdWardList.ExecuteReader()
            lstWardList.DataSource = drWardList
            lstWardList.DataTextField = "WARDNAME"
            lstWardList.DataValueField = "WARDCODE"
            lstWardList.DataBind()
            drWardList.Close()
            cnBarwickPas.Close()
        End If
Now this is working wonderfully, but the problem is i need to insert an entery into the list box say "Please choose a Ward from the list". So when the page loads the first option you see in the list is above.

Anyone have any ideas??

Thanks
Reply With Quote