Reputation: 1215
I am currently filling a bulleted list using the code below. It works fine but what I'd like to know is if it's possible to change the bullet style for a single list item if it meets some condition. Can this be done or do all the bullets in one list have to be the same? Any help is appreciated.
List<string> EventInfo = new List<string>();
//add list content here
for (int i = 0; i < EventInfo.Count; i++)
{
ListItem stuff = new ListItem();
if (!string.IsNullOrWhiteSpace(EventInfo[i]))
{
stuff.Text = EventInfo[i];
//check if condition is met and change bullet style for this item
BulletedList.Items.Add(stuff);
}
}
Upvotes: 0
Views: 2340
Reputation: 1
Using c# you can use below code:
BulletedList.Style.Add("list-style-type", "Circle");
Upvotes: 0
Reputation: 14253
You can do this with CSS, like this:
li
{
list-style-type:square;
}
Upvotes: 2
Reputation: 3820
First you'll need to define your css-style:
li.active { list-style-type:square; }
After that, you'll need to make sure your list-items actually get the required class based on your condition.
for (int i = 0; i < EventInfo.Count; i++)
{
ListItem stuff = new ListItem();
if (!string.IsNullOrWhiteSpace(EventInfo[i]))
{
stuff.Text = EventInfo[i];
//check if condition is met and change bullet style for this item
if(condition)
{
stuff.Attributes.Add("class", "active");
}
BulletedList.Items.Add(stuff);
}
}
Upvotes: 1