【问题标题】:Show defintion for GridView column name on mouse hover在鼠标悬停时显示 GridView 列名的定义
【发布时间】:2013-12-10 19:39:09
【问题描述】:

以下是我在客户端的 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,当用户将鼠标悬停在列名上时,我希望弹出一个小气泡,其中包含列名的定义:例如:-“日期”和“数字”和“名称”等。

我正在考虑使用 ajax、jquery 技术。

虽然我在互联网上进行研究,但如果你们中的任何人对这种技术有经验/可以指出正确的方向,我将不胜感激。

谢谢。

【问题讨论】:

标签: javascript jquery asp.net css gridview


【解决方案1】:

您可以在RowDataBound事件中设置每个标题列的ToolTip属性,如下所示:

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";
    }
}

【讨论】:

  • 有没有办法在 C# 中使用它来添加标题文本? protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { foreach (e.Row.Cells 中的 TableCell 单元格) { cell.Attributes.Add("Your Copay", "Testtestest " + 单元格. 文本); } } }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-01-07
  • 2013-12-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多