I have a dropdownlist that I already have manually databinding. I currently get the data, loop through each item, and depending on values in the item, change the css for the individual ListItem.
For example:
foreach (Site mySite in myList)
{
ListItem li = new ListItem(mySite.FullAddress, mySite.Id.ToString());
if (mySite.DisabledFlg)
{
li.Attributes.Add("style", "color:#999");
}
this.Items.Add(li);
}
I'm trying to force the text in the listitem to break at certain points. The string that I retrieve from the datasource currently has a "\r\n" everywhere where there should be a line break. This works fine for display in a normal textbox, but it doesn't work on the listitem.
I've tried replacing the "\r\n" with a "<br>"
but when I do that, it just displays <br>
in the listem along with the rest of the text. I've tried wrapping the listitem contents in a "div"
with a width attribute, but it also just display the "div"
tag literally in the ListItem text.
I've also tried adding the following to the ListItem attributes at bind:
li.Attributes.Add("width", "100px");
But that hasn't resulted in any change either.
I've seen custom drop down list controls that have multiline listitems in them. How do I acheive the same result?