gpt4 book ai didi

c# - 如何将额外的属性字段添加到 asp.net 下拉列表中

转载 作者:可可西里 更新时间:2023-11-01 08:39:43 27 4
gpt4 key购买 nike

下面我可以设置值和文本:

dropListUserImages.DataValueField = "Value";
dropListUserImages.DataTextField = "Text";
dropListUserImages.Items.Add(new ListItem { Text = srText, Value = srValue});

我还想设置额外的属性,例如:

data-imagesrc
data-description

我该怎么做?

最佳答案

使用:

ListItem test  = new ListItem { Text = srText, Value = srValue}
test.Attributes.Add("data-imagesrc", "xxx");
test.Attributes.Add("data-description", "xxx");
dropListUserImages.Items.Add(test);

关于c# - 如何将额外的属性字段添加到 asp.net 下拉列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14227254/

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