I have a dropdownlist and I want to add tooltip for dropdownlist items. I tried with following code, but it does not work;
for (int d = 0; d < drpID.Items.Count; d++)
{
drpID.Items[d].Attributes.Add("title", drpID.Items[d].Value);
}
Can anyone help me on this?
Try like this;
public void Tooltip(ListControl lc)
{
for (int d = 0; d < lc.Items.Count; d++)
{
lc.Items[d].Attributes.Add("title", lc.Items[d].Text);
}
}
You should use .Text
property for tooltip, not for .Value
.
Check out for this link: http://www.dotnetspider.com/resources/5099-Tool-tip-for-DropDownList-ASP-NET.aspx