Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
InitializeDataSource and Paging
posted

 This might be an easy question to answer.

 Here is our situation.  We have datasource that doesn't get bound to the WebGrid until after someone clicks on a "Search" button.  However, we want to use paging with the grid using this datasource.

The problem I'm seeing is that InitializeDataSource is executed on every PostBack.  When the initializedatasource is executed we may not even have a dataset at that time (first visit to page, etc) or even if a user decides to change the search criteria and "resets" the search params we would clear the datagrid of the dataset.

How are we able to use automatic paging in an AJAX environment if InitializeDataSource is required for paging?

  • 280
    posted

    Found a solution for the issue.

    Had to "hack" the InitializeDataSource so that it fires after the Page_Load instead of before.  The "hack" is just to define the event in the page.  Don't have to add code or anything to the function.  Pretty easy.

    When I did, everything fell into place.

     

    Thanks.