[英]Error in color drop down list items
我有以下方法,可以在运行时将项目添加到下拉列表中。 是添加好的商品,但商品没有任何样式出现
这里的下拉列表
<asp:DropDownList ID="ddlColorPicker" runat="server">
</asp:DropDownList>
这是我调用的用于在页面加载时添加项目的方法
protected void fillDDLFilesTypesColor()
{
ListItem l1 = new ListItem("بلا لون", "");
l1.Attributes.Add("style", "color:red");
l1.Attributes.Add("style", "background-color:#111111");
ListItem l2 = new ListItem("أحمر", "red");
l2.Attributes.Add("style", "color:red");
l2.Attributes.Add("style", "background-color:#111111");
ListItem l3 = new ListItem("أزرق", "blue");
l3.Attributes.Add("style", "color:blue");
l3.Attributes.Add("style", "background-color:#00FF7F");
ListItem l4 = new ListItem("أخضر", "green");
l4.Attributes.Add("style", "color:green");
l4.Attributes.Add("style", "background-color:#00FF7F");
ListItem l5 = new ListItem("أصفر", "yellow");
l5.Attributes.Add("style", "color:yellow");
l5.Attributes.Add("style", "background-color:#111111");
ddlColorPicker.Items.Add(l1);
ddlColorPicker.Items.Add(l2);
ddlColorPicker.Items.Add(l3);
ddlColorPicker.Items.Add(l4);
ddlColorPicker.Items.Add(l5);
}
您正在覆盖自己的风格。 一行完成所有操作,例如:
ListItem l2 = new ListItem("أحمر", "red");
l2.Attributes.Add("style", "background-color:#111111; color:red;");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.