Saturday, July 5, 2008

DropDownlist Tooltip for each item

Few days back one of my colleague wanted to show tool tip on each item, due to inappropriate rendering of contents of DropDownList. Below figure shows that DropDownlist Items are not coming completely due to small width of DropDownList and large data.



I searched on net but didn't find any appropriate solution for it.Then I thought to incorporate tooltip for each item. Here is the code to implement it.

string str = "Add Item in DDL ";
for (int i = 0; i < 11; i++)
{
DropDownList1.Items.Add(str + i.ToString());
DropDownList1.Items[i].Attributes.Add("title", str + i.ToString());
}

Title attributes add tooltip in each item in DropDownList.

Note : Title attribute doesn't work in IE 6.

Happy Coding :)

1 comment:

Anonymous said...

how to do it in IE6 sir

Site Meter