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
546
Urgent LoadOnDemand Problem
posted

Hi,

 

I'm using UWG 2008.2 (CLR 3.5) with the latest patch (.2.20082.2149).

The grid is set to LoadOnDemand="Xml" and the InitializeDataSource event is implemented.

Everything works fine and the grid loads additional date when scrolled down. The grid is inside an AJAX updatepanel. When the user selects a row and presses on a seperate edit button, I get the selected row from the grid and open a dialog in the buttons click event. This works just fine if the grid hasn't been scrolled down (hasn't been loading on demand). If the grid did load additional data the SelectedRows collection is always empty, eventhough a row was selected by the user.

I found out that the InitializeDataSource event is fired before the button click event. But the SelectedRows collection is already empty when InitializeDataSource is fired.

This is a huge problem for me and I urgently need a solution.

 

Thank you for your help.

 

 

Parents
No Data
Reply
  • 45049
    Suggested Answer
    posted

    sbitsolution said:
    The grid is set to LoadOnDemand="Xml" and the InitializeDataSource event is implemented.

    sbitsolution said:
    The grid is inside an AJAX updatepanel.
    This combination is likely part of the cause of your issue.

    WebGrid's AJAX functionality (LoadOnDemand="XML") uses a different AJAX implementation than used by the ASP.NET AJAX Extensions framework (used by UpdatePanel).  The two AJAX implementations cannot work at the same time.

    I recommend that you either replace UpdatePanel with WebAsyncRefreshPanel (which uses the same AJAX framework as WebGrid), replace WebGrid with WebDataGrid (which uses ASP.NET AJAX Extensions), or disable the AJAX functionality of WebGrid (and can continue using UpdatePanel).

    sbitsolution said:
    I found out that the InitializeDataSource event is fired before the button click event. But the SelectedRows collection is already empty when InitializeDataSource is fired.

    This is correct behavior, even disregarding the presence of an UpdatePanel.  When the grid's AJAX functionality is enabled, the grid recreates its rows from scratch during a postback.  The selected rows are not persisted on the server.

    One option is to disable the grid's AJAX functionality.  In this way, you can persist the grid's selected rows across postbacks.  You still have the UpdatePanel for AJAX functionality.  Depending on the reason you're using the grid's AJAX functionality, disabling it is likely the best option.

    Another option is to persist information about what was selected in some other fashion, so that you can access it on the server.  This is not a trivial undertaking, and exact details will depend greatly on your application's details.

Children