i have a dropdownlist that populates from the sql server database. populating the list is not a problem, but does anyone know how to populate the value part of the listitem.
<asp:dropdownlist id="colors">
<listitem value="1">black</listitem>
<listitem value="2">blue</listitem>
<listitem value="3">orange</listitem>
<listitem value="4">red</listitem>
<listitem value="5">violet</listitem>
how do you populate the value=1,2,3,4,5 when you’re populating from table in database?
First you have to build your select statement
You would store your query into a variable (I use “r” for return)
Then you need to attach it to the dropdown
If you really REALLY need to loop, then try something along these lines (not code is not checked, just a general idea.)
Or with the DataReader (again, untested, but prolly close)