gpt4 book ai didi

c# - 多值下拉列表

转载 作者:行者123 更新时间:2023-11-30 18:07:54 26 4
gpt4 key购买 nike

目前在 asp.net 中,DropDownList 中的 ListItem 中只能有一个值。但是我希望我可以:

<MultiValueDropDownList id="ddl" runat="server" />
ddl.Items.Add(new MultiValueListItem { Text="text", DBValue="db", EngineValue=1 });
var dbValue = ddl.SelectedItem.DBValue;

我要做的是继承DropDownList和ListItem。你们有更好的解决方案吗?

最后我决定选择偷懒的方式。将值存储在 ListItem.Attributes 中。并使用 DropDownList 的扩展方法来帮助获取值的集合。感谢您的帮助!

最佳答案

看看这是否有帮助:

EasyListBox

How to display multi-column in ASP Dropdown List?

asp.net : an alternative to multi-column DropDownList Gridview within dropdownlist / combobox (using the Ajax DropDownExtender)

编辑:

您不能从 ListItem 继承。

查看原因:Extending ASP.NET DropDownList

最好的解决方案是将值存储在 ListItem.Attributes 中。

关于c# - 多值下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3655950/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com