ASP.NET 绑定列工具提示
ASP.NET BoundColumn ToolTip
有没有办法向 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>
我之前使用的是 tablecell 并决定切换到绑定列,在这样做时我意识到工具提示不是绑定列的属性,我需要工具提示。
所以它实际上是一个 DataGrid
控件,您希望在 header-cell 上有一个工具提示。您可以使用 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
有没有办法向 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>
我之前使用的是 tablecell 并决定切换到绑定列,在这样做时我意识到工具提示不是绑定列的属性,我需要工具提示。
所以它实际上是一个 DataGrid
控件,您希望在 header-cell 上有一个工具提示。您可以使用 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