DropDownList属性(C#,ASP.net) [英] DropDownList Attributes (C#, ASP.net)

查看:131
本文介绍了DropDownList属性(C#,ASP.net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for(int i=1; i<=10; i++)
{
    li.Items.Add(new ListItem("Item" + i));
    if (i%2 == 0)
    {
       li.Items[i-1].Attributes["itemType"] = "Even";
    }
    else
    {
       li.Items[i-1].Attributes["itemType"] = "Odd"";
    }
}



我已经为li DropDownList的每个列表项添加了一个名为"itemType"的属性.但是我在下拉列表中选择其他项目后,无法获得分配给该属性的值.我认为,更改SelectedItem时,属性"itemType"也将被删除.

请帮我解决这个问题.
谢谢!



I''ve added each list item of the li DropDownList an attribute called "itemType". But I ''m not able to get the value assigned to that attribute after I select a different item in li Dropdownlist. I think the attribute "itemType" is also getting deleted when the SelectedItem is changed.

Please help me solving this.
Thank you!

推荐答案

项目必须保留.

参见

ASP.NET颜色下拉控件 [
The items need to be persisted.

see

ASP.NET Color DropDown Control[^]


这篇关于DropDownList属性(C#,ASP.net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆