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
100
ASP.Net UltraWebGrid export multi band to excel with load on demand
posted

Dear sir:

  I  have asp.net page with a ultragrid with band 0 and band 1 . it work fine for data display. the band 1 is used load on demand = manual. i tried to export the grid to the excel with ultrawebgridexcelexporter control to export the data to excel but the band 1 is missing..... is there any way or sample to export both band0 and band 1?

best regards

 

From Edmond LUI

Parents
  • 45049
    Suggested Answer
    posted

    WebGridExcelExporter will export to Excel those rows in the grid that have been loaded.  Thus, if you have three parent rows and expand the first two (to load their child data) before you export, you'll get child data for those parent rows but not for the third.

    This is the same reason why the Excel exporter only grabs the current WebGrid page (if paging is used), or only the first RowsRange worth of data (if the grid's AJAX functionality is used).

    To ensure that all rows are included in your export, I advise turning off load-on-demand (use a value of "NotSet" for DisplayLayout.LoadOnDemand). Instead, bind the grid so that it load alls data, at all levels.  You can do this during right before you call Export() on the Excel exporter.  Since you're using manual load-on-demand, this may require that you have access to a method or other process that allows you to get at all available data, rather than one data island at a time.

    Generally, so long as you're using the standard download mode, where the response sent to the browser is the Excel file itself, you don't even need to re-bind your grid to its original data.  This is because none of the changes should be persisted in any way, such as in ViewState; the client never gets any notification that a change was made.  By comparison, if you use a custom download mode or if you persist changes in some way (such as in Session state), you'll likely need to restore the state of your grid to where it was before you exported.

Reply Children