Hi,
Hi I am using asp:listbox in my code.
<td>
<asp:ListBox id="ddlWhereStudy" runat="server" rows="4"></asp:ListBox>
</td>
I want to color the listbox listitem conditionally. Please see the below code:
private void FillStudyWhereDropDown()
{
XmlNodeList objNodeList = FinalDoc.SelectNodes("//root/tcm:ListKeywords[@Type='StudyWhere']/child::tcm:Item", namespaceManager);
ddlWhereStudy.Items.Clear();
ddlWhereStudy.Items.Add(new ListItem(ResourceFile.GetResourceString("c_AdvisorOptionDefault")));
for (int i = 0; i < objNodeList.Count; i++)
{
string[] parts = objNodeList[i].Attributes["Title"].Value.Split('_');
ListItem li = new ListItem(parts[1], parts[2]);
ddlWhereStudy.Items.Add(li);
if (parts[3] == "B")
{
li.Attributes.Add("Style", "Color: 'RED'");
}
}
}
Above code is working fine when I am using select but it is not working with asp:ListBox
Please suggest!