本文介绍了Asp.net下拉列表DataValuefield和datatextfields的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面上有一个DropDownList控件,
我将同时绑定DataValueField和DataTextFiled.
例如:员工详细信息,
数据值字段= 1
数据文本字段="ABCD"
我希望dropdownlist中的文本显示如下
"1-ABCD"
我也想从此下拉列表中选择数据值字段"
上面的示例中多数民众赞成在1
我该怎么做
请帮助
I have a DropDownList Control in my page,
i am binding both DataValueField and DataTextFiled to it.
For example: Employee details,
Data value Field =1
Data Text Field ="ABCD"
i want the text in dropdownlist will show like this
"1-ABCD"
and also i want to select the Data Value Field from this dropdownlist
thats 1 in above example
How can i do this
Please help
推荐答案
SELECT
ID, TextF, (ID + '-' + TextF) AS IDTEXTF
FROM
MyTable
mydropdown.Datasource = myFetchedDataTable;
mydropdown.DataValueField = "ID";
mydropdown.DataTextField = "IDTEXTF";
mydropdown.Databind();
这篇关于Asp.net下拉列表DataValuefield和datatextfields的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!