如何在下拉列表的每一行中添加颜色。 [英] how to put color-in each row of a drop down list.

查看:84
本文介绍了如何在下拉列表的每一行中添加颜色。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how to put  color-in each row of a drop down list. Using data stored in SQL Server.

推荐答案

请参阅以下链接



使用C#的多色DropDownList [ ^ ]



-------------------





Refer below link

Multi-color DropDownList using C#[^]

-------------------
OR

<asp:DropDownList ID="DropDownList1" AppendDataBoundItems="true" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" OnLoad="DropDownList1_Load">
        <asp:ListItem Value="-1">Select</asp:ListItem>
        <asp:ListItem Value="0">Red</asp:ListItem>
        <asp:ListItem Value="1">Blue</asp:ListItem>
        <asp:ListItem Value="2">Green</asp:ListItem>
        <asp:ListItem Value="3">Violet</asp:ListItem>
</asp:DropDownList>










protected void DropDownList1_Load(object sender, EventArgs e)
{
        for (int i = 0; i < DropDownList1.Items.Count; i++)
        {
            DropDownList1.Items[i].Attributes.Add("styleackground-color:" + DropDownList1.Items[i].Text);
           
        }
}


这篇关于如何在下拉列表的每一行中添加颜色。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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