PC Review


Reply
Thread Tools Rate Thread

CSS classes on ListItems

 
 
Casper Hornstrup
Guest
Posts: n/a
 
      19th Sep 2005
How do I put a CSS class onto a ListItem of a drop-down list?
I've tried the following, but no class attribute is output in the HTML:

ddlChainSupplierAndNonChainDealer.DataSource =
GetChainSupplierAndNonChainDealerDataSource();
ddlChainSupplierAndNonChainDealer.DataValueField = "CompanyId";
ddlChainSupplierAndNonChainDealer.DataTextField = "Name";
ddlChainSupplierAndNonChainDealer.DataBind();
if (selectedIndex > 0)
ddlChainSupplierAndNonChainDealer.SelectedIndex = selectedIndex;
foreach (ListItem li in ddlChainSupplierAndNonChainDealer.Items)
li.Attributes["class"] = "forhandlerdrop_on";

The code is called from CreateChildControls().

Regards,
Casper Hornstrup


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot use ListItems when inheriting from DropDownList Nathan Sokalski Microsoft ASP .NET 1 17th Oct 2008 07:14 AM
how to put color in listitems of dropdownlist? Vincent Microsoft ASP .NET 3 7th Mar 2008 09:04 PM
ListItems and formatting Nathan Sokalski Microsoft ASP .NET 2 17th Aug 2007 02:23 AM
format listitems =?Utf-8?B?Um9sYW5k?= Microsoft Excel Programming 1 20th Dec 2004 08:40 PM
Serialize ListItems John Oakes Microsoft Dot NET Framework 0 2nd Feb 2004 06:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:04 AM.