I was searching for the way show Tooltips for headers of ASP.NET GridView control without using javascript or using unnecessary overhead in code. And I found the way how to do it. When you define columns or your GridView you should use TemplateField instead of BoundField cause it's customizable. In TemplateField you can define HeaderTemplate and put there Label control with needed Tooltip. Here is the code:
<asp:GridView ID="GridView" DataSourceID="ObjectDataSource1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField SortExpression="ShareCount">
<HeaderTemplate>
<asp:Label runat="server" Text="Nr. of Stocks" ToolTip="Total number of stocks on the market"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("ShareCount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
No comments:
Post a Comment