Saturday, April 4, 2009

Indentation in list item text

While working with dropdownlist control once i was required to dispaly indented text for specific list items, in many of my attempts to achieve this i failed the continueing in search of solution i found this and really a very simple one:

ddl.Add(New ListItem(Server.HtmlDecode("nbsp;nbsp;") & "Maincat1","Maincat1"))
ddl.Add(New ListItem("subcat1-1"))
ddl.Add(New ListItem("subcat1-2"))
ddl.Add(New ListItem(Server.HtmlDecode("nbsp;nbsp;") & "Maincat2","Maincat2"))
ddl.Add(New ListItem("subcat2-1"))
ddl.Add(New ListItem("subcat2-2"))

*ddl is the name dropdownlist on my aspx page.

No comments: