SIGN UP MEMBER LOGIN:    
Resource

Adding Title to the Dropdown list Items

Hemant Kumar Resources Jan 18, 2012
This is a simple task to do when we add the Items directly to the dropdown list in the HTML markup.
This is a simple task to do when we add the Items directly to the dropdown list in the HTML markup. Some time we feel difficulty when we add the Items from the database.
I hope this common method will solve the problem. This common method can be used to add any style to the Items also.

public void AddAttributesToItems(DropDownList ddl)
    {
        foreach (ListItem item in ddl.Items)
        {
            if (item.Value != "-1")
            {
                item.Attributes.Add("title", item.Value);
            }
        }
    }
share this resource :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Sponsored by
Nevron Gauge for SharePoint
Become a Sponsor