1 workaround is to add the item one-by-one using a loop, rather than performing data binding. The "tooltip" of a ListItem can be set through its "Attributes" collection as follow:
- ListItem li = new ListItem("Text", "Value");
-
li.Attributes["title"] = "Tooltip";
There is a problem -- Unlike "Text" and "Value" properties, values set through "Attributes" collection will not persist on postback. This mean, if this method is used, you will have to set the tooltip on every postback.
An example here: The ASP.NET page contains a CheckBoxList named "cbl" and a Button that simply performs a postback. The CheckBoxList displays a list of file names from "C:\" folder. For each ListItem, file name is set as "Text" and full file name is set as "Value". The file creation time is set as "tooltip". Instead of performing data binding, I use a foreach loop to populate the ListItems. The codes are written within the Page_PreInit event handler (not sure if this is the appropriate place). I set its "EnableViewState" property to "False". As I populate the ListItems on every postback, there is no point to turn it on.
- Using System.IO;
-
...
-
protected void Page_PreInit(object sender, EventArgs e)
-
{
-
DirectoryInfo dir = new DirectoryInfo(@"C:\");
-
FileInfo[] files = dir.GetFiles();
-
foreach (FileInfo file in files)
-
{
-
ListItem li = new ListItem(file.Name, file.FullName);
-
li.Attributes["title"] = file.CreationTime.ToString();
-
cbl.Items.Add(li);
-
}
-
}
Well. It may not be what you really want. Anyway, I hope at least this can give you an additional alternative idea to get your problem solved.