473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

CheckBoxList Population and ToolTip

Hi,

I have a CheckBoxList in web form and I am populating the list items from the database in the page_load event. Now for each list item i have to set the tool tip using the value from the database.

Expand|Select|Wrap|Line Numbers
  1.                 CheckBoxList1 .DataTextField = "Name";
  2.                 CheckBoxList1.DataValueField = "Description";
  3.                 CheckBoxList1.DataBind();
  4.  
Any idea please.

Thanks
Manoj.
Apr 15 '10 #1
4 6131
Frinavale
9,735 Expert Mod 8TB
Arulmanoj, as far as I know there is no "tooltip" for list items in a CheckBox list.
You could very well add JavaScript to each item so that when you hover over the item it displays a description

-Frinny
Apr 15 '10 #2
Hi Frinny,

Thanks for your reply.

I don't know javascript. Can you please help me to write the javascript for the same. Sorry for asking this.

Thanks

Manoj.
Apr 16 '10 #3
liawcv
33
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:

Expand|Select|Wrap|Line Numbers
  1. ListItem li = new ListItem("Text", "Value");
  2. 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.

Expand|Select|Wrap|Line Numbers
  1. Using System.IO;
  2. ...
  3. protected void Page_PreInit(object sender, EventArgs e)
  4. {
  5.     DirectoryInfo dir = new DirectoryInfo(@"C:\");
  6.     FileInfo[] files = dir.GetFiles();
  7.     foreach (FileInfo file in files)
  8.     {
  9.         ListItem li = new ListItem(file.Name, file.FullName);
  10.         li.Attributes["title"] = file.CreationTime.ToString();
  11.         cbl.Items.Add(li);
  12.     }
  13. }
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.
Apr 16 '10 #4
liawcv
33
Another workaround is to place a single CheckBox (note: CheckBox has a Tooltip property) within a multiple-row DataBound control such as GridView, DataList, Repeater, ListView, etc. When the page is running, you will get a group of individual CheckBoxes.

To check which CheckBoxes have been checked, you will have to visit each data row one-by-one. A bit "dirty", but still workable... : )
Apr 16 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Curious Angel | last post by:
Help? Spec Character Problems w/JAVASCRIPT TOOLTIP Hi, I'm experiencing bizarre problems with quote marks that previously displayed properly in a Javascript TOOLTIP I wrote a year ago . . . and...
0
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all...
4
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected...
4
by: Shaul Feldman | last post by:
Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmatically. I add CheckBoxList's Items on the fly, something...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
2
by: LisaBigJax | last post by:
I am using a series of checkbox's in a repeater -- (not the checkboxlist) -- the problem I am encountering is that the checkbox does not have a value attribute. I tried to add it via the...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.