Hi amar,
Refer below sample.
HTML
<asp:DropDownList runat="server" ID="drdVerification" Style="width: 150px;" OnSelectedIndexChanged="drdVerification_SelectedIndexChanged"
AutoPostBack="true">
<asp:ListItem Text="Need to ask" Value="A" Selected="True"></asp:ListItem>
<asp:ListItem Text="Incorrect" Value="I"></asp:ListItem>
<asp:ListItem Text="Correct" Value="C"></asp:ListItem>
<asp:ListItem Text="New" Value="N"></asp:ListItem>
<asp:ListItem Text="Asked - not verified" Value="Q"></asp:ListItem>
<asp:ListItem Text="Not applicable" Value="X"></asp:ListItem>
<asp:ListItem Text="NDB Already Updated" Enabled="false" Value="B"></asp:ListItem>
<asp:ListItem Text="Prov Resp Not Avail NDB" Enabled="false" Value="P"></asp:ListItem>
</asp:DropDownList>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
this.SetDropDownListItemColor();
}
private void SetDropDownListItemColor()
{
foreach (ListItem item in drdVerification.Items)
{
if (item.Text.Trim().ToLower() == "need to ask")
{
item.Attributes.CssStyle.Add("color", "red");
}
else
{
item.Attributes.CssStyle.Add("color", "blue");
}
}
}
protected void drdVerification_SelectedIndexChanged(object sender, EventArgs e)
{
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Me.SetDropDownListItemColor()
End Sub
Private Sub SetDropDownListItemColor()
For Each item As ListItem In drdVerification.Items
If item.Text.Trim().ToLower() = "need to ask" Then
item.Attributes.CssStyle.Add("color", "red")
Else
item.Attributes.CssStyle.Add("color", "blue")
End If
Next
End Sub
Protected Sub drdVerification_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Screenshot