【问题标题】:ASP.NET BoundColumn ToolTipASP.NET BoundColumn 工具提示
【发布时间】:2015-12-28 05:47:36
【问题描述】:

有没有办法向 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>

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

【问题讨论】:

  • 您希望该列中每一行的单元格都使用相同的工具提示,甚至是页眉和页脚?
  • 不,在我将工具提示放在列标题之前,我有 10 个不同的列,它们都有不同的工具提示。我也想这样做。
  • 属于这些列的每一行的单元格应该有这个工具提示还是只有标题?
  • 只有标题。如果我有一个名为 Name 的列,我希望能够滚动到列标题并查看工具提示。我不需要列中的每个单元格。
  • 这是GridView吗?

标签: asp.net vb.net tooltip boundcolumn


【解决方案1】:

所以它实际上是一个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

【讨论】:

    猜你喜欢
    • 2014-07-26
    • 2011-04-15
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-19
    相关资源
    最近更新 更多