c# - gridview 中的分页

标签 c# asp.net .net gridview page-index-changed

我的 GridView :

              <asp:GridView ID="gridView1" runat="server" CellPadding="4" AllowPaging="true" PageSize="5"  emptydatatext="No data available." 
                    CssClass="datagrid" 
                    ForeColor="#333333" GridLines="None" 
                    onrowcreated="gridView1_RowCreated" 
                    onpageindexchanging="gridView1_PageIndexChanging">

                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>

还有我的代码隐藏:

    protected void gridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gridView1.PageIndex = e.NewPageIndex;
        BindDataGrid();
    }



    protected void BindDataGrid()
    {

        DataSet ds = new DataSet();

        ds = dbM.GetInfo(name, mobilePhone, info1); //get info to BD and save in "ds"

        gridView1.DataSource = ds;
        gridView1.DataBind();
    }

并且“寻呼”不起作用。显示前5行,但不显示分页数

怎么了???

请帮忙

谢谢

最佳答案

尝试在 GridView 标记中添加一些分页器设置:

<PagerSettings Mode="NextPreviousFirstLast" Position="TopAndBottom" />

如果有效,您可以将其更改为您想要的外观。有many choices ,包括

  • 首页图像网址
  • 首页文本
  • LastPageImageUrl
  • 最后一页文本
  • 模式(例如数字或 数字第一个最后)
  • NextPageImageUrl
  • 下一页文本
  • 页面按钮计数
  • 职位
  • 上一页图像网址
  • 上一页文本
  • 可见`

关于c# - gridview 中的分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6224998/

相关文章:

.net - 像 Reflective 这样的 .NET 反汇编程序可以访问原始源代码中的注释吗?

c# - 科学计数法 - .NET 中的错误?

c# - 如何在 C# 中创建事件对象模式 TypedActor

asp.net - 如何使 ASP CheckBoxList 标签与复选框保持在同一行

asp.net - ASP :DropDownList in ItemTemplate: Why is SelectedValue attribute allowed?

c# - 带有 Angular 6 的 .Net Framework 4.5 中的 CORS 问题

c# - 无法使用 GetManifestResourceStream() 加载 list 资源

c# - 如何从 C# 应用程序调用 (Iron)Python 代码?

c# - 使用 ObjectDataSource 对 GridView 进行排序不是排序

c# - 形状与 DrawingVisual 的性能