Asp.net
如何在滑鼠懸停在網格視圖列標題上添加工具提示
當使用者將滑鼠懸停在 gridview 中列的列標題上時,例如: Column Heading Year,當我將滑鼠懸停在 Year 上時,我應該看到該年份的解釋“這是學生加入大學的年份等”。
下面是我的 ascx 程式碼:
<asp:GridView ID="grdView" runat="server" Width="900px" AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true" CellSpacing="0" CellPadding="5" PageSize="20" OnRowDataBound="grdView_RowDataBound"> <Columns> <asp:TemplateField HeaderText="ID Number" ItemStyle-Width="90px" > <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID")%'></asp:Label> </ItemTemplate> </asp:TemplateField><asp:BoundField DataField="StudentName" HeaderText="StudentName"> </asp:BoundField>請讓我知道如何將滑鼠懸停在網格視圖的列標題上的文本或工具提示上。謝謝,
我從來沒有做過任何asp.net開發,但是這裡似乎提供了一個解決方案:how to add title for each header column in gridview in ASP.NET
您的範例可能如下所示:
<asp:GridView ID="grdView" runat="server" Width="900px" AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true" CellSpacing="0" CellPadding="5" PageSize="20" OnRowDataBound="grdView_RowDataBound"> <Columns> <asp:TemplateField HeaderText="ID Number" ItemStyle-Width="90px" > <HeaderTemplate> <asp:Label ID="Header" ToolTip="HERE WE GO!!!!" runat="server" Text="Label"></asp:Label> </HeaderTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID")%'></asp:Label> </ItemTemplate> </asp:TemplateField><asp:BoundField DataField="StudentName" HeaderText="StudentName"> </asp:BoundField>我會試試看:)
protected void grd_popup_details_RowDataBound(object sender, GridViewRowEventArgs e) { for (int i = 0; i < e.Row.Cells.Count; i++) { e.Row.Cells[i].ToolTip = e.Row.Cells[i].Text; } }
