Grid View Pagination.

Posted by Wondering on Stack Overflow See other posts from Stack Overflow or by Wondering
Published on 2009-08-08T09:39:10Z Indexed on 2010/04/22 2:03 UTC
Read the original article Hit count: 404

Filed under:
|
|
|

Dear All, I have a grid view and I want to implement Pagination functionality.This is working fine.

 protected DataSet FillDataSet()
{
    string source = "Database=GridTest;Server=Localhost;Trusted_Connection=yes";
    con = new SqlConnection(source);
    cmd = new SqlCommand("proc_mygrid", con);
    ds = new DataSet();
    da = new SqlDataAdapter(cmd);
    da.Fill(ds);
    GridView1.DataSource = ds;
    GridView1.DataBind();
    return ds;


}
 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
   int newPagenumber = e.NewPageIndex;
   GridView1.PageIndex = newPagenumber;
   GridView1.DataSource = FillDataSet();
   GridView1.DataBind();

}

But the problem is for each pagination I have to call FillDataSet(); Is there any way to stop that.Any other coding approach? Thanks.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about ADO.NET