Binded DropDownList with ToolTip
Solution 1
Simply call that function after dropdown list binding: BindTooltip(Name of the dropdownlist);
public void BindTooltip(ListControl lc)
{
for (int i = 0; i < lc.Items.Count; i++)
{
lc.Items[i].Attributes.Add("title", lc.Items[i].Text);
}
}
Solution 2
http://www.codeproject.com/KB/aspnet/List_Box_Tool_Tip.aspx
http://www.dotnetspider.com/resources/5099-Tool-tip-for-DropDownList-ASP-NET.aspx
Solution 3
Below code will work, need to call this method in PageLoad and pass the dropdown list to the method for which you want tooltip
protected void Page_Load(object sender, EventArgs e)
{
BindToolTip(ddlProjects);
}
Below is the actual method:
private void BindToolTip(ListControl list)
{
foreach (ListItem item in list.Items)
{
item.Attributes.Add("title", item.Text);
}
}
rob waminal
I am an average programmer, spending my spare time helping others here in SO. I am currently working as a Software Engineer specialized in ASP.NET MVC 1,2,&3, C#, WCF Service Application, MS Commerce Server 2007 & 2009. SOreadytohelp
Updated on August 02, 2022Comments
-
rob waminal almost 2 years
Hi I have a DropDownList bounded from the code behind. How can I use the
DataTextField
as a ToolTip of the DropDownList?DropDownList list = this.DropDownList1; list.DataSource = GetData(); list.DataTextField = "DisplayString"; list.DataValueField = "DataValue"; list.DataBind();
I want the bounded Field
DisplayString
to bounded also in the ToolTip. Is this possible without using theDataBound
event of the DropDownList? -
rob waminal over 13 yearsclose, but I want the tooltip for each list item, not only on the selected item.
-
Myra over 13 yearssame thing can be implemented on hover effect as well