Click here to Skip to main content
15,921,636 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How set the tooltip for Dropdown control ..give some examples
Posted
Comments
Sergey Alexandrovich Kryukov 16-Jun-11 4:48am    
Tag it! APS.NET, Forms, WPF, what?!
--SA

After databinding
you can loop all listitems and add title attribute.
C#
foreach (ListItem item in cmb.Items)
            {
                item.Attributes.Add("Title", item.Text);
            }
 
Share this answer
 
hi,



C#
public string ToolTip
    {
        get { EnsureChildControls(); return ddl.ToolTip; }
        set { EnsureChildControls(); ddl.ToolTip = value; }
    }



XML
ad this code on code behind and set tooltip property in page load
ToolTip= "select country"


where ddl is the name of the dropdown list

happy coding
 
Share this answer
 
Hope this[^] might help you.
 
Share this answer
 
You can use given sample code to adding tooltip to DropDownList. you need to just adding Title attribute to the list item in DataBound event.
<asp:dropdownlist id="DropDownList1" runat="server" ondatabound="DropDownList1_DataBound" xmlns:asp="#unknown">
</asp:dropdownlist>

and Now below code in Code behind file
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
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900