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