用HTML版上的控件,并把此DropDownList1转化成服务器控件使用.
定制的方式:
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);
}