DataGrid Question

Discussion in 'ASP.NET / ASP.NET Core' started by mikew_houston, Apr 22, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello,

    I have a question about the DataGrid.
    ?
    My grid displays data from a table with a lot of data, so I need to page. I have a few text boxes where i can enter parameters to filter the data by.

    On the first form load I return the top 100 records 10/page.

    I then enter some parameters and click a button, and the gird is reloaded, if I page, I throw an exception:
    pageindex needs to be > 0 or < 10

    What is going on?

    Thanks
    Michael
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    can you post the whole error

    and the code snippet.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. You may have to do this:

    private void myTable_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
    {
    try
    {
    myTable.CurrentPageIndex = e.NewPageIndex;
    BindData();
    }
    catch {}
    }

    Also make sure you're re-binding the datagrid every page refresh.
     
  4. Hell Everyone,

    I want to thank you all for your help.

    I found the problem. I was filtering the data and redisplaying the grid.

    I add the following code:

    DataGrid.CurrentPageIdex = 0

    before I undated the DataSource and Bound the Grid.

    Thanks,

    Now it works! [​IMG]
     
  5. Good catch.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page