有没有办法将工具提示添加到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并决定切换到绑定列,这样做我意识到工具提示不是boundcolumn的属性,我需要工具提示。
答案 0 :(得分:2)
所以它实际上是一个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