2013-11-25 24 views
2

以下是我在客戶端的Gridview的代碼。在鼠標懸停上顯示GridView列名的定義

<asp:GridView ID="gvwClaims" runat="server" AllowPaging="true" PageSize="20" 
      OnPageIndexChanging="gvwClaims_PageIndexChanging" 
      OnRowDataBound="gvwClaims_RowDataBound" 
       RowStyle-CssClass="GridViewRowStyle" HeaderStyle-CssClass="GridViewHeaderRowStyle" 
       AlternatingRowStyle-CssClass="GridViewAlternatingRowStyle" AutoGenerateColumns="false" 
       BorderStyle="None" CellPadding="2" OnRowCommand="gvwClaims_RowCommand"> 
          <HeaderStyle CssClass="GridViewHeaderRowStyle" /> 
          <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" /> 
          <PagerStyle CssClass="gridPagerStyle" /> 
          <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" /> 
       <Columns> 
        <asp:BoundField DataField="DateFrom" HeaderText="Date"> 
         <ItemStyle Width="50" /> 
        </asp:BoundField> 
        <asp:TemplateField HeaderText="Number"> 
         <ItemTemplate> 
          <asp:LinkButton ID="ClaimLink" runat="server" CommandName="View" CssClass="GridLink" 
           Visible='<%# ((String)Eval("HPType") == "number") %>' Text='<%# Eval("No") %>'></asp:LinkButton><asp:Label 
            runat="server" ID="NoLink" Visible='<%# ((String)Eval("Type") == "number") %>' 
            Text='<%# Eval("No") %>'></asp:Label> 
         </ItemTemplate> 
        </asp:TemplateField> 
        <asp:BoundField DataField="Prov" HeaderText="Name"> 
         <ItemStyle /> 
        </asp:BoundField> 
        <asp:BoundField DataField="PlcSvc" HeaderText="Place"> 
         <ItemStyle /> 
        </asp:BoundField> 
        <asp:BoundField DataField="HpType" HeaderText="Plan"> 
         <ItemStyle /> 
        </asp:BoundField> 
        <asp:BoundField DataField="Status" HeaderText="Status" /> 
       </Columns> 
       <EmptyDataTemplate> 
        <div id="pnlEmptyClaims" runat="server" class="NoRecs"> 
         <span style="font-style: italic">No recent history is available.</span></div> 
       </EmptyDataTemplate> 
          <RowStyle CssClass="GridViewRowStyle" /> 
      </asp:GridView> 

我有一個GridView,我想使列名難以處理。

在過去,我使用div元素和css代碼來更改鼠標指針懸停,然後鼠標單擊事件。

但是現在我想要使用這個gridview,當用戶將鼠標懸停在列名上時,我想要一個小的氣泡來彈出列名的定義:例如: - 「Date」和「Number」和「名稱」等。

我正在考慮使用ajax,jQuery技術。

雖然我在互聯網上進行研究,但是如果你們中任何一個有這方面的經驗/我可以指出我正確的方向,我將不勝感激。

謝謝。

+0

我想這個答案適用於你的問題:http://stackoverflow.com/a/10727278/28327 – Kosta

回答

3

您可以設置每個標題欄的ToolTip財產在RowDataBound事件,像這樣:

protected void gvdetails_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    // Only do this to the header row, ignore data and footer rows 
    if(e.Row.RowType==DataControlRowType.Header) 
    { 
     e.Row.Cells[0].ToolTip = "Date header tooltip text here"; 
     e.Row.Cells[1].ToolTip = "Number header tooltip text here"; 
     e.Row.Cells[2].ToolTip = "Name header tooltip text here"; 
     e.Row.Cells[3].ToolTip = "Place header tooltip text here"; 
     e.Row.Cells[4].ToolTip = "Plan header tooltip text here"; 
     e.Row.Cells[5].ToolTip = "Status header tooltip text here"; 
    } 
} 
+0

有沒有辦法在C#中使用它來添加標題文本? 保護無效GridView_RowDataBound(對象發件人,GridViewRowEventArgs E) { 如果(e.Row.RowType == DataControlRowType.Header) { 的foreach(在e.Row.Cells TableCell的小區) { cell.Attributes.Add (「您的Copay」,「Testtestest」+ cell.Text); } } } – Philo