0

有没有办法向 BoundColumn 添加工具提示?这是我的代码....

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

我之前使用的是表格单元并决定切换到绑定列,这样做我意识到工具提示不是绑定列的属性,我需要工具提示。

4

1 回答 1

2

所以它实际上是一个DataGrid控件,您希望在标题单元格上有一个工具提示。您可以使用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

如果是GridView,则代码类似:

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
于 2015-09-30T13:14:36.307 回答