用Html控件吧,好像服务器控件,难以实现。

解决方案 »

  1.   

    用<Select></select>DropDownList没办法,不知道是不是BUG<select runat="server" id="color">
    </select>
    for(int i=0;i<10;i++)
    {
        color.items.add(.........);
        color.items[i].attributes["style"]="color:#ffffff;background-color:#ffffff";
    }
      

  2.   

    It's a bug,try:
    http://www.c-sharpcorner.com/Code/2003/July/DropDownListBox.asp
      

  3.   

    作用定制的方式: DropDownList1.Items.Add(new ListItem("默认","white"));
    DropDownList1.Items.Add(new ListItem("红色","red"));
    DropDownList1.Items.Add(new ListItem("兰色","blue"));
    DropDownList1.Items.Add(new ListItem("紫色","SandyBrown"));
    DropDownList1.Items.Add(new ListItem("青色","Aqua"));
    DropDownList1.Items.Add(new ListItem("黄色","Yellow"));
    for (int i= 0 ;i < DropDownList1.Items.Count;i++)
    {
    DropDownList1.Items[i].Attributes.Add("style", "background-color:" + DropDownList1.Items[i].Value);
    }
      

  4.   

    用HTML版上的控件,并把此DropDownList1转化成服务器控件使用
    <SELECT id="DropDownList1" style="Z-INDEX: 104; LEFT: 256px; WIDTH: 208px; POSITION: absolute; TOP: 72px"
    name="DropDownList1" runat="server">
    </SELECT>