G
gnosys
In ASP.Net 1.1 using C#, I'm trying to dynamically change the
background colors of certain listbox items based on some criteria. For
example:
[ Select Items ]
[Item 1]
[Item 2]
[Item 3 (Hot) ]
[Item 4]
[Item 5 (Hot ]
In the ListBox above, I would like the Items that are "Hot" to have a
red background. This box will obviously be populated from a dataset,
and my code time is like this:
foreach (myItem i in myItems)
{
ListItem li = myListBox.FindByValue(i.itemValue);
if (!i.IsHot)
continue;
if (li != null)
li.Attributes.CssStyle.Add("background-color", "yellow");
}
No Compilation errors, I have tried other ways to do this, didn't
work. However, if I just do ListBox.Attributes.CssStyle - it changes
the bg color of all the items. I only need to change the background of
certain items. Any help will be appreciated.
}
background colors of certain listbox items based on some criteria. For
example:
[ Select Items ]
[Item 1]
[Item 2]
[Item 3 (Hot) ]
[Item 4]
[Item 5 (Hot ]
In the ListBox above, I would like the Items that are "Hot" to have a
red background. This box will obviously be populated from a dataset,
and my code time is like this:
foreach (myItem i in myItems)
{
ListItem li = myListBox.FindByValue(i.itemValue);
if (!i.IsHot)
continue;
if (li != null)
li.Attributes.CssStyle.Add("background-color", "yellow");
}
No Compilation errors, I have tried other ways to do this, didn't
work. However, if I just do ListBox.Attributes.CssStyle - it changes
the bg color of all the items. I only need to change the background of
certain items. Any help will be appreciated.
}