tags:

views:

50

answers:

3

I have a table which has an Id and a name field. I usually bind the name to the dropdownlist but I was told that any dml should be on the Id so how can I use the name in the dropdownlist and at the same time still use the Id?

A: 

You can set the dropdownlist's Text field to the name and the Value field to the ID.

Aaron
A: 

A very similar question was just answered a little while ago - here

Ray
+2  A: 

Use DataTextField and DataValueField when binding:

ddlList.DataSource = thesource;
ddlList.DataTextField = "Name";
ddlList.DataValueField = "ID";
ddlList.DataBind()

Where ID and Name are fields in your data source.

Paddy