How to make a DropDownList control display some elements in bold ASP.NET

I am working with a custom DropDownList control in ASP.Net, and I am prompted to display certain items in a bold list (NOTE: The control is inherited from CompositeDataBoundControl, so it may be related data ... not DropDownListBox). The control is bound to a table, and there is a column in the table named IsUsed - if this parameter is set to true, the corresponding element in the list should be highlighted in bold. (It should be noted here that this can only be seen in FireFox.)

My experience is everything in the middle \ backend levels, so the presentation level is very insignificant for me - can someone point me in the right direction? My initial thought was that somewhere in the user control I would have access to all the rows that are returned from the data source that I could scroll, etc., but I'm not sure if this is possible .. There are also RenderContents that I can override ... looks interesting!

+5
source share
3 answers

OK. I think I answered my question, but it does not look very elegant.

proc , , ID . TRUE FALSE ( IsUsed ). RenderContents , bool , , bool ...

+1

:

var item = new ListItem("MyItem");
item.Attributes.Add("style", "font-weight: bold");

var list = FindControl("DropDownList1");
list.Items.Add(item);

, System.Web.UI.Control, Attributes, style.

+3

, , html , html . JavaScript jQuery custom.

+1
source

All Articles