c# - 如何在 Gridview 分页器中将 NextPageText/NextPageUrl 从 "..."更改为 "Next"?

标签 c# asp.net gridview paging

以下是我的 GridView 分页器标记

<PagerSettings Mode="NumericFirstLast" PageButtonCount="3" 
    FirstPageImageUrl="~/images/First.jpg" 
    LastPageImageUrl="~/images/Last.jpg" 
    NextPageImageUrl="~/images/Next.jpg" 
    PreviousPageImageUrl="~/images/Prev.jpg" />

但是,当我运行它时,我得到默认的“...”作为链接按钮来导航到下一页和上一页。第一个和最后一个按钮导航链接按钮正确显示为图像。

有人可以告诉我出了什么问题吗?

编辑 1

我使用 NextPageText 也得到了相同的结果

最佳答案

我也遇到了同样的问题,我用这段代码解决了:

Protected Sub grdPatsCliente_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles grdPatsCliente.RowCreated
    If e.Row.RowType = DataControlRowType.Pager Then
        Dim i As Integer = 0
        For Each ctl As Control In e.Row.Cells(0).Controls(0).Controls(0).Controls
            i += 1
            If ctl.Controls(0).GetType.ToString = "System.Web.UI.WebControls.DataControlPagerLinkButton" Then
                Dim lnk As LinkButton = CType(ctl.Controls(0), LinkButton)
                If lnk.Text = "..." Then
                    If i < 3 Then
                        lnk.Text = "Prev"
                    Else
                        lnk.Text = "Next"
                    End If
                End If
            End If
            Dim x As String = ctl.ClientID
        Next
    End If
End Sub

默认的 Gridview 分页器始终在下一个和上一个链接上呈现“...”。使用此代码,我将“...”替换为我的文本(如果您使用 FontsAwesome ,也可以使用 HTML,如“”)

C# 代码:

protected void grdPatsCliente_RowCreated(object sender, GridViewRowEventArgs e) {
    if (e.Row.RowType == DataControlRowType.Pager) {
        int i = 0;
        foreach (Control ctl in e.Row.Cells[0].Controls[0].Controls[0].Controls) {
            i++;
            if (ctl.Controls[0].GetType().ToString() == "System.Web.UI.WebControls.DataControlPagerLinkButton") {
                LinkButton lnk = (LinkButton)ctl.Controls[0];
                if (lnk.Text == "...") {
                    if (i < 3) {
                        lnk.Text = "Prev";
                    } else {
                        lnk.Text = "Next";
                    }
                }
            }
        }
    }
}

关于c# - 如何在 Gridview 分页器中将 NextPageText/NextPageUrl 从 "..."更改为 "Next"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11429145/

相关文章:

c# - 如何使我的页面在文档查看器中居中?

c# - 使用嵌入式资源打开 Excel 工作簿文件

c# - 在 ubuntu 16.04 上安装 "monodevelop"IDE 后找不到 asp.net 模板

c# - ASP.NET Gridview ButtonField onclick 触发包含行的 onclick 事件

c# - Visual Studio 2010 错误的 Crystal 报表

c# - Unity 2.0 和处理 IDisposable 类型(尤其是使用 PerThreadLifetimeManager)

javascript - 如何添加带有图像的选项以在页面加载期间进行选择?

asp.net - 将鼠标悬停在文本上时更改字体颜色

javascript - 基于GridView中的另一个控件动态启用GridView中的ASP.net按钮

powershell - 为Out-GridView列添加自定义对象