473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

listbox/dataset question

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.
Nov 19 '05 #1
2 969
Rob
After your call to DataBind() add this line:

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

Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #2
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.

"Rob" wrote:
After your call to DataBind() add this line:

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

Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mathieu cupryk | last post by:
I have problems with listboxes in the webform2.cs, the textboxes are working well when I do a click on next. I am missing something. It works with the textboxes. Here is the file: using System;...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
2
by: Rob | last post by:
I have a listbox which is populated by a dataset: 'initiate the DataSet and all the rest here my sql statement is this: SELECT company_id, name, description FROM companies ds =...
3
by: Robert W. | last post by:
I have a SQL Server table called "ClosedMonths" that contains two pertinent fields: Yearx Monthx 2000 1 2000 2 2000 3 I want to simply query this...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.