单击页码时不返回下一页 [英] on clicking page number does not return next page

查看:101
本文介绍了单击页码时不返回下一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击第2页时,它将返回同一页.
然后我再次单击它返回下一页,但没有上一页数据.
我的gridview是....

When I click page number 2 it returns same page.
And I click again it returns next page but previuos page data.
My gridview is....

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

            CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" 

            ToolTip="Double click for Detail" 

            onpageindexchanging="GridView1_PageIndexChanging"  align="center"

            onrowdatabound="GridView1_RowDataBound" 

          PageSize="10" 

            ShowFooter="True" Caption="Full Detail" onselectedindexchanged="GridView1_SelectedIndexChanged" 

         >
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" Font-Size="Small" />
            <Columns>
                <asp:BoundField DataField="punchdate" HeaderText="PUNCH DATE" />
                <asp:BoundField DataField="timein" HeaderText="IN TIME">
                <ItemStyle HorizontalAlign="Left" />
                 </asp:BoundField>
                <asp:BoundField DataField="timeout" HeaderText="OUT TIME">
                 </asp:BoundField>
            </Columns> 
           <FooterStyle BackColor="#5D7B9D"  ForeColor="White" />
                   <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <selectedrowstyle backcolor="#E2DED6" forecolor="#333333" />
                   <HeaderStyle BackColor="#5D7B9D"  ForeColor="White" Font-Size="Medium" />
                  <EditRowStyle BackColor="#999999" />
                   <AlternatingRowStyle BackColor="PaleGoldenrod" />
        </asp:GridView>

和pageindexedchange事件代码

and pageindexedchange event code

protected void GridView1_PageIndexChanging(object sender,GridViewPageEventArgs e)
       {
          GridView1.PageIndex = e.NewPageIndex;
           GridView1.SelectedIndex = -1;
                 }


我该怎么办?


What should I do?

推荐答案

看起来像您忘记了重新绑定gridview一样.您需要做的就是增加页数并重新绑定网格. .NET将自动显示正确的行.

在这里,请看以下示例文章:
MSDN:ASP.NET 2.0的GridView示例:对GridView的数据进行分页和排序 [ ^ ]
ASP.NET中的GridView分页示例 [ ^ ]
Looks like you forgot to rebind the gridview. All you need to do is increase the page count and rebind the grid. .NET will automatically show the correct rows.

Here, have a look at these sample article:
MSDN: GridView Examples for ASP.NET 2.0: Paging and Sorting the GridView''s Data[^]
GridView Paging Sample in ASP.NET[^]


再次绑定网格视图...


Bind your gridview again...


GridView1.PageIndex = e.NewPageIndex;
GridView1.SelectedIndex = -1;
bindgrid();




谢谢




Thanks


创建会话
Session["grid"] = ds;
protected void GridView1_PageIndexChanging(object sender,GridViewPageEventArgs e)
        {
           GridView1.PageIndex = e.NewPageIndex;        
            GridView1.SelectedIndex = -1;
GridView1.DataSource=Session["grid"] ;
GridView1.DataBind();
                  }


这篇关于单击页码时不返回下一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆