Combo/Drop down box

cadwalli

Active member
Joined
May 27, 2010
Messages
41
Location
United Kingdom
Programming Experience
10+
Hi

I have a form in aspx (code in vb.net) which has several bits of information which i write back to a database table.

Most of these fields are text fields.

However, I also have a couple of combo boxes which at the moment I write back to the db using e,g.:

dbfield = dropdown1.text

then when i load the data back in to the form i use:

dropdown1.text = dbfield

However, is this the safest way to do it? what if the text values on the forms change.

Should i be writing dropdown1.value back to the table instead as that would always be constant, i.e. if my combo had value "OPEN" and text "OPEN-TICKET" and i changed the text to "OPEN" only then the value OPEN would still be valid.

I know this sounds like an obvious question but I dont seem to be able to get things to work if i use the value.

Am i missing something.

Thanks in advance.

Ian
 
Use the value class, but put it as Value.tostring. The Value parameter might pass the ascii code if something goes wrong, so if you use that its just the same as dropdown1.text only, as you say, constant! :)
use .text for writing back into the field, that is pretty much the same.
 
Back
Top