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?
From stackoverflow
-
You can set the dropdownlist's
Textfield to the name and theValuefield to the ID. -
A very similar question was just answered a little while ago - here
-
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.
0 comments:
Post a Comment