在asp.net的Gridview中分页的问题 [英] Problem with Paging in Gridview in asp.net

查看:72
本文介绍了在asp.net的Gridview中分页的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

asp.net的Gridview中的分页问题
=======================================

朋友,我是拉赫曼.

正在使用asp.net c#,sqlserver2005.

Gridview分页面临问题.

我的网页上有一个Gridview.并使用分页填充数据.

我在gridview中有成千上万的记录.我曾经为此做分页.

1,2,3,4,5 ........................... 500.

当我单击第2、3、4页...并且当我单击返回第一页时,它不在第一页.

这是面临的问题.请帮我寻求更好的解决方案.

特别感谢.

Problem with Paging in Gridview in asp.net
==========================================

Hi Friends, This is Rahman.

am working on asp.net c#, sqlserver 2005.

am facing problem with Gridview paging.

I have a Gridview on my WEBPAGE. and filled data in it with Paging.

I have thousands of records in gridview. i used to do Paging for it.

1,2,3,4,5...........................500.

when i click on pages 2,3,4... and when i click back to the 1st page it doesnot comes to first page.

this is the problem am facing. Please help me for better solution.

Special thanks.

推荐答案

<asp:gridview id="Gridview1" runat="server" autogeneratecolumns="False" allowpaging="True" onpageindexchanging="Gridview1_PageIndexChanging" xmlns:asp="#unknown"></asp:gridview>





static DataTable dt;//Globally in class

 Gridview1.DataSource = dt;
            Gridview1.DataBind();


protected void Gridview1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        Gridview1.PageIndex = e.NewPageIndex;
        Gridview1.DataSource = dt;
        Gridview1.Page.DataBind();
    }



这将为您提供适当的帮助



This will help you properly


是的,先生,

我使用了gridview页面索引更改事件,并将allow分页属性设置为true.


受保护的void GridView1_PageIndexChanging(对象发送者,GridViewPageEventArgs e)
{

GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();

}


请给我一个好的解决方案.
yes sir,

I used gridview Page Index changing Event, and set allow paging properties to true.


protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{

GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();

}


Please give me a good solution.


这篇关于在asp.net的Gridview中分页的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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