To highlight a particular item in a DropDownList

//The following function describes the code to highlight a particular item in a DropDownList. Here i have assumed that that the

DropDownList name is dlSelectedAction

private void HighLight()

{

foreach (ListItem item in dlSelectAction.Items)

{

if (item.Value.Equals(“the index of the item”))

{

item.Attributes.Add(“class”, “categoryItemStyle”);

//Here you need to create a class in your stylesheet (.css file) that has the name “categoryItemStyle” as shown below.

In that class you can specify the background color of your choice using background-color property.

You can use another class name too.

}

}

}

.categoryItemStyle
{
background-color: red;
}

Follow

Get every new post delivered to your Inbox.