我怎么能额外属性字段添加到asp.net下拉列表 [英] How can i add extra attribute fields to the asp.net dropdown list
本文介绍了我怎么能额外属性字段添加到asp.net下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧像下面我能够设定值和文本
Ok like below i am able to set value and the text
dropListUserImages.DataValueField = "Value";
dropListUserImages.DataTextField = "Text";
dropListUserImages.Items.Add(new ListItem { Text = srText, Value = srValue});
我也想设置额外的属性,如
I also want to set extra attributes such as
data-imagesrc
data-description
我怎样才能做到这一点?谢谢
How can i do that ? thank you
推荐答案
使用:
ListItem test = new ListItem { Text = srText, Value = srValue}
test.Attributes.Add("data-imagesrc", "xxx");
test.Attributes.Add("data-description", "xxx");
dropListUserImages.Items.Add(test);
这篇关于我怎么能额外属性字段添加到asp.net下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文