Friday, April 15, 2011

DataGrid Paging

Hi, I am using VB.Net 2005, with IE7. I have a datagrid where I have set paging "AllowPaging" = True However, when I click the link to the next page, the records are still the same.

My code is:

ds = SQLHelper.ExecuteDataset(strConn, 
      CommandType.StoredProcedure, "GetInventory")
dv = ds.Tables(0).DefaultView
dgInvestoryList.DataSource = dv
dgInvestoryList.DataBind()

What am I missing?

From stackoverflow
  • If you are using the Wizard with the SqlDataSource, then paying will be there all ready.

    But if you go and place your code in the code behind you will have to do something like this - sorry i dont have the code for VB.NET - Must place code in the PageIndexChanging event. Use this This link to change my C# code to VB.NET, i use it ALOT

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            try
            {
                DataSet ds = new DataSet();
                GridView1.DataSource = ds;
                GridView1.PageIndex = e.NewPageIndex;
                this.GridView1.DataBind();
            }
            catch (Exception)
            {
                Response.Redirect("Login.aspx");
            }
    
        }
    
    Etienne : They are very similar, but cant tell u exaclty what the diff. is. But trust me, use a datagrid! Its alot easier and you can do alot more with it. Cheers and good luck

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.