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

Setting Value of Dropdown List from Array

I am trying to set the value of items in a dropdown list dynamically, and
can't seem to figure out how to do it.

I have two arrays set up like this:

Dim a() as string ={"A", "B", "C"}
Dim b() as string ={"1", "2", "3"}

I can get the first array in the items list like this:

DrpDwnLst1.Datasource = a
DrpDwnLst1.Databind()

However, I need to also set the values for each item in string a to the
values in string b. I know you can create a dataset for pulling that info
out of a db, but can't find anything in the help files that tells you how to
do it with an array.

Apparently, DataMember, DataTextField, and DataValueField are for setting
the items one by one, or by referring to a dataset, but they don't seem to
work with an array. Any help on how to do this would be appreciated.

George

Nov 18 '05 #1
1 2956
Ignore this question. I was finally able to figure it out.

George

"George" <------@----.---> wrote in message
news:3Z**********************@bgtnsc05-news.ops.worldnet.att.net...
I am trying to set the value of items in a dropdown list dynamically, and
can't seem to figure out how to do it.

I have two arrays set up like this:

Dim a() as string ={"A", "B", "C"}
Dim b() as string ={"1", "2", "3"}

I can get the first array in the items list like this:

DrpDwnLst1.Datasource = a
DrpDwnLst1.Databind()

However, I need to also set the values for each item in string a to the
values in string b. I know you can create a dataset for pulling that info
out of a db, but can't find anything in the help files that tells you how to do it with an array.

Apparently, DataMember, DataTextField, and DataValueField are for setting
the items one by one, or by referring to a dataset, but they don't seem to
work with an array. Any help on how to do this would be appreciated.

George

Nov 18 '05 #2

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

Similar topics

2
by: Tapiwa JONGWE | last post by:
I would like to display 15 items (lines) in the dropdown list, but by default the list displays only 11 lines. How can I have all the 15 items displayed in my dropdown list ? Thanks for your...
0
by: Raja | last post by:
I have an .aspx form with Microsoft Tab on it.There are about 4 Tabs with each one having a Dropdown List.When the page is loaded it fetches value from the database and Sets the value as selected...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
4
by: nz mark in aus | last post by:
Hi there I am populating an empty <asp:dropdownlist on the client side using Javascript using the following code Heres my dropdown list <asp:dropdownlist id="ddlDealers"...
5
by: =?Utf-8?B?bWNhdWxpZmZl?= | last post by:
I have an old application ( pre-VB5) that I need to add a select/option list to. This is an edit program so the values for the form will be retrieved from a database. How do I set the value of...
5
by: =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?= | last post by:
Hello. I am reading a value from a table and trying to determine if that value exists in a list of values associated with a dropdownlist. If so, I select the value, otherwise, I don't. I haven't...
5
by: Rotsey | last post by:
Hi, I have a combobox that when I set the SelectedIndex to -1 it sets to 0. The combobox Items property says there is 20 items in it. Anyone know why this could be please? rotsey
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
3
by: John | last post by:
I have two dropdown lists that I have bound to a datatable and set the DataTextField and DataValueField for. Both lists show the values I expect from the database. However, when I need to access...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.