0

Is there a way to add a tool tip to a BoundColumn? This is my code....

    <asp:BoundColumn DataField="PersonName" SortExpression="PersonName" HeaderText="Name">
        <HeaderStyle HorizontalAlign="Center" Width="10%" VerticalAlign="Top"></HeaderStyle>
        <ItemStyle HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle>
    </asp:BoundColumn>

I was using a tablecell before and decided to switch to a bound column, in doing so I realized tooltips are not an attribute of boundcolumn, I need tooltips.

Louis Royster
  • 111
  • 1
  • 12

1 Answers1

2

So it's actually a DataGrid control and you want to have a tooltip on the header-cell. You can use ItemDataBound:

Protected Sub SortableDataGrid_ItemDataBound(sender As Object, e As DataGridItemEventArgs) Handles Grid0.RowDataBound
    Select Case e.Item.ItemType
        Case ListItemType.Header
            'presuming it's the first column:
            e.Item.Cells(0).ToolTip = "Your tooltip for this header cell"
    End Select
End Sub

If it's a GridView the code is similar:

Protected Sub SortableGridView_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles Grid0.RowDataBound
    Select Case e.Row.RowType
        Case DataControlRowType.Header
            'presuming it's the first column:
            e.Row.Cells(0).ToolTip = "Your tooltip for this header cell"
    End Select
End Sub
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939