2

我的网格视图:

              <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 行,但不显示分页数

怎么了???

请帮忙

谢谢

4

3 回答 3

2

尝试在标签中添加一些寻呼机设置:GridView

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

如果可行,您可以将其更改为您想要的外观。有很多选择,包括

  • FirstPageImageUrl
  • 第一页文本
  • LastPageImageUrl
  • 最后一页文本
  • 模式(例如 Numeric 或 NumericFirstLast)
  • NextPageImageUrl
  • 下一页文本
  • 页面按钮计数
  • 位置
  • 上一页图片网址
  • 上一页文本
  • 可见`
于 2011-06-03T09:06:12.243 回答
2

PagerSettings -Property 添加到 GridView-Markup 并将其设置为True

PagerSettings-Visible="true"

编辑:但它应该是true默认的,所以我不确定这是否会改变任何东西

于 2011-06-03T09:07:26.280 回答
2
 Use **"PageIndexChanged"**

protected void gridView1_PageIndexChanged(object sender, GridViewPageEventArgs e)
        {
            try
            {
                gridView1.PageIndex = e.NewPageIndex;
                BindDataGrid();
    ;
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
于 2011-06-03T09:15:23.410 回答