This is a migrated thread and some comments may be shown as answers.

Custom tooltip for one column

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 08 Dec 2011, 12:29 PM
I'm looking to add a tooltip to a certain column in my grid, lets says its called 'TestColumn'. How do i go about adding a tooltip to cells  in just that column and not the others. At the moment i am applying a tooltip to each cell as follows:
if (e.Item is GridDataItem)
       {
           foreach (TableCell cell in e.Item.Cells)
           {
               if (cell.Text != " ") cell.ToolTip = cell.Text;
           }
       }

How do i modify this to take the column 'TestColumn' into account?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2011, 12:50 PM
Hello,

Try the following code snippet.
CS:
protected void grid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem gridItem = e.Item as GridDataItem;
           TableCell cell = gridItem["ColUniqueName"];
           cell.ToolTip = cell.Text;
       }
   }

Thanks,
Princy.
0
Michael
Top achievements
Rank 1
answered on 08 Dec 2011, 01:14 PM
Excellent, that did exactly what i needed, thank you :)
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Michael
Top achievements
Rank 1
Share this question
or