trip
trip

Reputation: 73

ASP.NET: Insert Multiple Values from a Dropdownlist into Database

How can I insert two different values into columns of a table in a database when both values come from the same DropDownList? For example one value is 'name' and the other is 'id'.

Upvotes: 1

Views: 2273

Answers (1)

st mnmn
st mnmn

Reputation: 3667

If I understand your situation. the 'name' value is the DataTextField in the dropDown, and the 'id' value is the DataValueField in the dropDown. so,

If it's realy like that, it simple to do it, you have to take the: DropDownList1.Items[ DropDownList1.SelectedIndex].Text - this is the 'name' value, and the: DropDownList1.SelectedValue - this is the 'id' value.

Upvotes: 3

Related Questions