20
webdrown list item background color
posted

Hi, 

I am using webdrop down as below and was able to bind the data from code behind. I can see my dropdown options as A, B, C, D. How can I change the background color of each item i.e. A should have background color of Green, B should have background color of Red, C should have background color of Orange, D should have background color of Purple. 

 <ig:WebDropDown ID="wdBooks" runat="server" Width="200px"  OnDataBound="wdBooks_DataBound"></ig:WebDropDown>

I tried below approach as starting point but doesnt seem to be working.

protected void wdBooks_DataBound(object sender, EventArgs e)
{
foreach (Infragistics.Web.UI.ListControls.ListItem myItem in wdBooks.Items)
{
//Set the item background-color like so:
myItem.Attributes.Add("style", "background-color:Blue");
}
}

Parents
  • 1960
    Offline posted

    Hi pradeep,

    You can set the background color of each item of the WebDropDown list by setting each item's CssClass property 

    myItem.CssClass = "myItem";

    and then style it in your css file.

Reply Children
No Data