Databind hasktable to a Drop Down List box using the key as the value...

S

Stu Lock

Hi,

Is there any way to databind a hashtable to a drop down list box using the
key/value pair within the hashtable to correspond to the value/text of the
drop down list box?

ie: hashtable with values:

key=1, value=item 1
key=2, value= item 2

to load a drop down liek:

<select>
<option value=1>item 1</option>
<option value=2>item 2</option>
</select>

Thanks in advance,

Stu
 
K

Karl

ddl.DataSource = someHash;
ddl.DataTextField = "key";
ddl.DataValueField = "value";
ddl.DataBind();

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top