About the author

Vijay Kodali
E-mail me Send mail

Recent comments



The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

To add Tool Tip for DropDownList items in Asp.Net

Here is sample code for adding tooltip to DropDownList. The key here is adding "title" attribute to the list items in DataBound event.

<asp:DropDownList ID="DropDownList1" runat="server" ondatabound="DropDownList1_DataBound">
In code behind ..
protected void DropDownList1_DataBound(object sender, EventArgs e)
    DropDownList ddl = sender as DropDownList;
    if (ddl != null)
        foreach (ListItem li in ddl.Items)
           li.Attributes["title"] = li.Text; // setting text value of item as tooltip


Posted by vijay on Thursday, October 11, 2007 9:15 PM
Permalink | Comments (1) | Post RSSRSS comment feed


Bob United States

Wednesday, February 8, 2012 4:09 PM


Great solution, others didn't work since I was doing a databind to my dropdownlist.  

One note... if the dropdownlist isn't visible by default, but becomes visible due to another event, you need to re-bind the data for this to add the attribute to the items.  Otherwise the attribute isn't retained when going from visible to hidden.  I accomplished this by doing the data bind on page load regardless of whether or not it was a postback.  Took me a while to figure out why it wasn't working at first, though.

Add comment

(Will show your Gravatar icon)

  Country flag

  • Comment
  • Preview