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

Best Way to Create a ToolTip in GridHyperLinkColumn

2 Answers 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel Kraft
Top achievements
Rank 2
Joel Kraft asked on 27 Jan 2014, 04:29 PM
I have a grid with a GridHyperLink column and I would like to have a tooltip displayed for the link.  What is the best way to do this?  I understand that I can change it to a GridTemplateColumn and create everything myself, but I was hoping there was a way to do it in ItemDataBound or in another event.

Thanks,
Joel

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Jan 2014, 03:42 AM
Hi Joel,

You can try out the following code to set the tooltip for the GridHyperLinkColumn. You can use the ItemDataBound event of the grid to achieve this.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem gridItem = e.Item as GridDataItem;
        foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns)
        {
            if (column is GridHyperLinkColumn)
            {
                (gridItem[column.UniqueName].Controls[0] as HyperLink).ToolTip = (gridItem[column.UniqueName].Controls[0] as HyperLink).Text;
            }
        }
    
}

Thanks,
Princy
0
Joel Kraft
Top achievements
Rank 2
answered on 28 Jan 2014, 04:15 AM
Ahh... that is it!

I was trying to set .ToolTip on the GridHyperLinkColumn, rather than the hyperlink control in the column.

Thanks!
Tags
Grid
Asked by
Joel Kraft
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Joel Kraft
Top achievements
Rank 2
Share this question
or