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
2010-04-20 15:46:45
+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
2010-04-20 15:51:13