DropDownList中保存一个更大的价值 [英] DropDownList holds one more value
本文介绍了DropDownList中保存一个更大的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的DropDownList
有该项目的文本和值属性被设置主键条目。是的,我与显示文本属性主键和值属性查询。
我想也得到所选项目的其他财产,如姓名无需查询集
结合的DropDownList
或查询数据库。
我怎么能这样做?
< ASP:DropDownList的ID =DDL=服务器>
< ASP:ListItem的文本=项目编号VALUE =项目编号>< / ASP:ListItem的> //我要拿到项目的名称
< / ASP:DropDownList的>
解决方案
的DropDownList
ASPX标记:
< ASP:DropDownList的ID =ddlDropDown=服务器>
< ASP:ListItem的文本=项目编号VALUE =项目编号ThirdValue =ITEMNAME/>
< / ASP:DropDownList的>
找回价值是这样的:
列表项项= ddlDropDown.Items.FindByValue(项目编号);
字符串值= item.Attributes [ThirdValue];
I have dropdownlist
which has items that text and value property of the item are set to primary key. Yes, I show primary key with text property and querying with value property.
I want also to get selected item's other property such as name without querying dataset
that binds to dropdownlist
or querying database.
How can I do that?
<asp:DropDownList ID="ddl" runat="server">
<asp:ListItem Text="ItemID" Value="ItemID"></asp:ListItem> // I want get item's name
</asp:DropDownList>
解决方案
DropDownList
Aspx Markup :
<asp:DropDownList ID="ddlDropDown" runat="server">
<asp:ListItem Text="ItemID" Value="ItemID" ThirdValue="ItemName" />
</asp:DropDownList>
Retrieve value like this :
ListItem item = ddlDropDown.Items.FindByValue("ItemID");
string value = item.Attributes["ThirdValue"];
这篇关于DropDownList中保存一个更大的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文