ASP.NET:插入多个值从一个DropDownList到数据库 [英] ASP.NET: Insert Multiple Values from a Dropdownlist into Database
问题描述
我怎样才能插入两张不同的值在数据库中的表的列当两个值都来自同一个DropDownList的?例如一个值是'姓名',另一个是'编号'。
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'.
推荐答案
如果我理解你的处境。
在名称值是 DataTextField
在下拉菜单
,
和id值是 DataValueField
在下拉列表中。
因此,
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,
如果这是真的这样,它简单的事,你必须采取: DropDownList1.Items [DropDownList1.SelectedIndex]。文本
- 这是'名字'值, DropDownList1.SelectedValue
- 这是id值
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.
这篇关于ASP.NET:插入多个值从一个DropDownList到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!