Results 1 to 4 of 4

Thread: datagridview paging

  1. #1
    Fanatic Member
    Join Date
    Oct 06
    Posts
    650

    datagridview paging

    I set the AllowPaging = True and use this code

    Code:
        protected void GridView1_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            GridView1.DataBind();
        }
    but it still doesn't show the records in 2nd, 3rd and so on...

  2. #2
    Frenzied Member
    Join Date
    Feb 08
    Location
    Texas
    Posts
    1,237

    Re: datagridview paging

    You have to assign the datasource again as well. So you have to re-query or just store the datasource (datatable, etc) globally and .Datasource = x and DataBind().

    Justin
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  3. #3
    Fanatic Member
    Join Date
    Oct 06
    Posts
    650

    Re: datagridview paging

    how? i have this code to connect the data source

    Code:
            SqlConnection oConn = new SqlConnection(ConfigurationManager.AppSettings["constring"]);
    
            DataSet dsGrid = new DataSet();
    
            SqlDataAdapter cmdGrid = new SqlDataAdapter("spGetOrder", oConn); //Where sp is stored procedure name
            cmdGrid.SelectCommand.CommandType = CommandType.StoredProcedure;
            cmdGrid.SelectCommand.CommandTimeout = 300;
    
            cmdGrid.Fill(dsGrid, "Orders");
    
            DataView dv = new DataView(dsGrid.Tables["Orders"]);
    
            grdOrders.DataSource = dv;
    
            grdOrders.DataBind();

  4. #4
    Frenzied Member
    Join Date
    Feb 08
    Location
    Texas
    Posts
    1,237

    Re: datagridview paging

    vb Code:
    1. Private Sub SetOrdersDataSource()
    2.  
    3.         SqlConnection oConn = new SqlConnection(ConfigurationManager.AppSettings["constring"]);
    4.  
    5.         DataSet dsGrid = new DataSet();
    6.  
    7.         SqlDataAdapter cmdGrid = new SqlDataAdapter("spGetOrder", oConn); //Where sp is stored procedure name
    8.         cmdGrid.SelectCommand.CommandType = CommandType.StoredProcedure;
    9.         cmdGrid.SelectCommand.CommandTimeout = 300;
    10.  
    11.         cmdGrid.Fill(dsGrid, "Orders");
    12.  
    13.         DataView dv = new DataView(dsGrid.Tables["Orders"]);
    14.  
    15.         grdOrders.DataSource = dv;
    16.  
    17.         grdOrders.DataBind();
    18.  
    19. End Sub
    20.  
    21.  
    22.     protected sub GridView1_PageIndexChanging(sender as object ,  e as System.Web.UI.WebControls.GridViewPageEventArgs)
    23.    
    24.         GridView1.PageIndex = e.NewPageIndex;
    25.         BindOrdersDataSource()
    26.         GridView1.DataBind();
    27.  
    28.     end sub
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •