473,406 Members | 2,620 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,406 software developers and data experts.

Dropdown question

I have a dropdown that I load a list of values from a database. If I have
more that one value returned from a search I want to populate the dropdown
and have the first value be "<Select Run>". Then have the person use the
dropdown to select the item. If only one item is found, then I show the
item in the dropdown and load its values without a problem. Here is the
code I use to populate the dropdown. How would I add the <Select Runitem
after binding to the datatable?:

If dtCrushing.Rows.Count 1 Then

With cboCrushingRunNumber

.DataSource = dtCrushing

.DisplayMember = "Run_Nbr"

.ValueMember = "RunID"

.SelectedIndex = 0

End With

Else

'load the data

LoadCrushingData(dtCrushing)

End If
Nov 9 '07 #1
1 1171
There may be a better way, but what I would do, is to not 'bind' the combobox
to your datasource, but to load the the combobox 'items' collection from your
rows. Then you just have to remember that combobox.selectedindex will be 1
greater then the row it represents. So, something like this ...

If dtCrushing.Rows.Count 1 Then
cboCrushingRunNumber.Items.Add("<Select Run>")
For each dr as DataRow in dtCrushing.Rows
cboCrushingRunNumber.Items.Add(dr.Item("Run_Nbr"). ToString)
Next
.SelectedIndex = 0
Else

'load the data

LoadCrushingData(dtCrushing)

End If
--
Terry
"John Wright" wrote:
I have a dropdown that I load a list of values from a database. If I have
more that one value returned from a search I want to populate the dropdown
and have the first value be "<Select Run>". Then have the person use the
dropdown to select the item. If only one item is found, then I show the
item in the dropdown and load its values without a problem. Here is the
code I use to populate the dropdown. How would I add the <Select Runitem
after binding to the datatable?:

If dtCrushing.Rows.Count 1 Then

With cboCrushingRunNumber

.DataSource = dtCrushing

.DisplayMember = "Run_Nbr"

.ValueMember = "RunID"

.SelectedIndex = 0

End With

Else

'load the data

LoadCrushingData(dtCrushing)

End If
Nov 10 '07 #2

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

Similar topics

1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
1
by: HalaszJ | last post by:
Is there no work around for this? >-----Original Message----- >I have asked this question on about every board I can >think of and I have yet to get an answer, so If anyone >would know I...
3
by: phil2phil | last post by:
hi, had a question on preloading a dropdown. we have a textbox and dropdown on the page, user is suppose to enter in a zip into textbox, then the dropdown should load the state based on the zip. ...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
0
by: Pietje puk | last post by:
Hello, Since im quite new to ASP.NET i wanted to ask you folks what the best way is to create a WebForm for modifying 1 field from a record. The manipulation of this field can be done by using...
3
by: Jon | last post by:
I am using cascading dropdowns, where the selection in one determines what fills another. In regular ASP I simply loaded a giant dataset into javascript array and when you clicked on one dropdown,...
4
by: AccessRookie | last post by:
Ok, I am pretty new to Access (Using Access 2002 at my job). Here is what I want to do. I want to create a database that has a form. On this form will be a dropdown menu (combobox). Depending...
5
by: Kassad | last post by:
Two questions: 1. There is a dropdown box that has a whole bunch of values but it is not linked to a recordsource. I believe when this object was created the values were manually enterred but I...
4
by: Paul | last post by:
Hi all, I have a page that has a form on it which has a dropdown list on it. It connect to an sql database and populate the list. What I would like to do is make the list editable so that if the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.