Saturday, March 24, 2012

Simple combo box question

How can I set both the 'value' and 'text' properties of a combobox in asp.net ( vb ) ?

I can do this for the text property ( ie the bit that gets displayed ) - but what is the syntax for doing this for the associated value ?

Obviously this is easily done using html, but how is it done through 'raw' code ?

I'm picking up values from a database lookup table and trying to populate a combobox with both text AND values, so I can pick up the 'codified value' when storing back to the db.

thanks in advance
KDHi,

DropDown.datatextfield="DisplayValue"
DropDown.datavaluefield="Value"

HTH
But this is not vb code, its HTML isnt it, or have I missed something ?
use this


Dim lst As ListItem
lst = New ListItem
lst.Text = "YourText"
lst.Value = "YourValue"
DropDownList1.Items.Add(lst)

0 comments:

Post a Comment