listbox/dataset question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to add an extra row (option) above the list that I create via a
dataset.
I've tried adding a datatable to add a row but can't seem to get it to work.
I'd rather keep it as a dataset. Code:

ddrmaapprovby = listbox

Dim dstEmployees As DataSet
Dim dadEmployees As SqlDataAdapter

dstEmployees = New DataSet
SqlConnect = New SqlConnection(ConnectString)
Dim sqlstring As String = "SELECT CONTACT_ID, CONTACT_LNAME + ', ' +
CONTACT_FNAME AS [FULLNAME] FROM CONTACTS WHERE CONTACT_ROLE = 'EMPLOYEE'
ORDER BY [FULLNAME]"
dadEmployees = New SqlDataAdapter(sqlstring, SqlConnect)
dadEmployees.Fill(dstEmployees, "CONTACTS")

'bind
ddrmaapprovby.DataSource = dstEmployees
ddrmaapprovby.DataMember = "CONTACTS"
ddrmaapprovby.DataTextField = "FULLNAME"
ddrmaapprovby.DataValueField = "CONTACT_ID"
ddrmaapprovby.DataBind()

I want to put in an option like text = (please select) and the value be
blank ("")

thanx.
 
After your call to DataBind() add this line:

ddrmaapprovby.Items.Insert(0, New ListItem("(please select)")

Rob
 
thanx! I added the value to along with the text to this and it works great!
I've been using add and didn't know about insert.
 
Back
Top