473,799 Members | 2,988 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically fill a selectbox

I would like to fill a Selectbox dynamically.
I am taking all values from a db, and fill them into a selectbox.
I guess the best way was to use some kind of a dynamical array, where you
don't have to say how many
elements it will contain.
In Java there exists special containers to achieve that, but what about VB?
I thought about somethign like that:

select year from db

while dynamischesArra y.AddNewValue(n extResult)

How to get this done as easy and good as possible?

Thanks,

Stefan
Nov 20 '05 #1
3 2661
For aWebForm, if you mean by selectbox a ListBox, then here is an example:

For ds a DataSet, states.xml an XML file containing a list of states with
Field1 containing the state abbreviation, you would do the following to
populate the list box DropDownStateLi st:

ds.Clear()
ds.ReadXml(Serv er.MapPath(".") & "\states.xm l")
Me.DropDownStat eList.DataSourc e = ds
Me.DropDownStat eList.DataTextF ield = "Field1"
Me.DropDownStat eList.DataBind( )
For aWindowsForm, and a ComboBox, it would be something like

ds.Clear()
ds.ReadXml("..\ states.xml")
Me.ComboBoxStat e.DataSource = ds.Tables(0)
Me.ComboBoxStat e.DisplayMember = "Field2" 'name
Me.ComboBoxStat e.ValueMember = "Field1" 'abreviation

"Stefan Richter" <sp**@spammenot .com> wrote in message
news:c7******** ***@otis.netspa ce.net.au...
I would like to fill a Selectbox dynamically.
I am taking all values from a db, and fill them into a selectbox.
I guess the best way was to use some kind of a dynamical array, where you
don't have to say how many
elements it will contain.
In Java there exists special containers to achieve that, but what about VB? I thought about somethign like that:

select year from db

while dynamischesArra y.AddNewValue(n extResult)

How to get this done as easy and good as possible?

Thanks,

Stefan


Nov 20 '05 #2
I found it by myself:

Dim yearArrayList As New ArrayList

While (MyDataReader.R ead())

yearArrayList.A dd(MyDataReader .Item("year"))
Nov 20 '05 #3
* "Stefan Richter" <sp**@spammenot .com> scripsit:
I found it by myself:

Dim yearArrayList As New ArrayList

While (MyDataReader.R ead())

yearArrayList.A dd(MyDataReader .Item("year"))


What's a selectbox? The questions remains unanswered ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

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

Similar topics

2
2843
by: Jon | last post by:
Hi all, I am trying to dynamically fill an array with any unique values from a field (objRS.Fields(5)) in my database with the following code below. However it errors with "The array is fixed or temporarily blocked" for the line "REDIM PRESERVE UserArray(Arraycount+1)". I can't seem to get around this. Any suggestions? Many thanks. Dim p Dim UserArray(0) ' Max number of users
2
1604
by: RelaxoRy | last post by:
I have 3 texfield boxes 1. firstname 2. lastname 3. username When a person enters in their firstname and lastname, I want the username field to fill with firstnameLastinitial. Eg. Firstname = Adam, Lastname = Apple, Username = AdamA
2
6627
by: John Scott | last post by:
Hi there, I have a PDF that has editable form fileds. I want to be able dynamically fill in those form fields based on values I provide to the PDF. Right now, I can create an instance of the object, open the PDF document, but can't get a handle on the JavaScript portion of the document in order to change any of the form field values. Here is a snippet of my code so far: Type AcroApp = Type.GetTypeFromCLSID(new...
1
2178
by: Zameer Syed | last post by:
I have a webform in which users enter their information and there is a button at the end of form,which when clicked should open a word document with fields filled in dynamically with the information the user enters in the webform.I hope you understand what i mean.I am trying to do that.Could you please suggest how i could do that. Thanks, Zameer
3
2114
by: Advertis | last post by:
Is there a way to populate a dropdown in a GridView with the next x years? I am using a GridView to display data from a SQL table One of the fields is a Year. I want to have the dropdown list not only the year in the db field, but also the current year to the next x years. Any ideas?
4
1855
by: blg002 | last post by:
All I am trying to do is dynamically fill the "Your Price" field with a number that is the product of the value of "acres" "regularity" and 10. The annoying part is I had it working yesterday and can't figure out what I did to break it. Link.. http://www.gdarb.com/jj/estimate.html Javascript... function autofill() { document.estimate.price.value = "$" + document.estimate.acres.value * document.estimate.regularity.value * 10 + " per...
5
11291
by: buntyindia | last post by:
Hi, I have three Listbox on my jsp page. I want to do following: ByDefault first list will be filled by database, When User select something from 1st list box second will fill accordingly by database using Ajax. When user select something from 2nd list third will get data.
0
1062
by: sravan_reddy001 | last post by:
I am developing a e-news website.. i bought space from websuvidha.org.. they are also providing some emails... http://mail.asianmedianetworkinc.com/ http://216.157.131.123/index.php the above are the links for the mail server.. now i have the details of each account that can login to my website..
0
1405
by: malsh1358 | last post by:
I created Jaxb java classes and now I want to fill them dynamically , but I dont know how I can dynamically fill JAXB java objects (I can do it in fix way) ,I must say that their data are in xml file to fill java objects , please help me.
0
10475
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10026
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.