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
Thks for you explaination
I tried to set the DisplayLayout.LoadOnDemand = LoadOnDemand.NotSet but the child row still not appear (even i expand the sub band). my code is below
if (Request.Form["uniqueKey"] != null) { if (Session["Unit_DataSet" + Session.SessionID + "_" + Request.Form["uniqueKey"].ToString()] != null) { ds = (DataSet)Session["Unit_DataSet" + Session.SessionID + "_" + Request.Form["uniqueKey"].ToString()]; }
} this.UltraWebGrid1.DisplayLayout.Pager.AllowPaging = false; this.UltraWebGrid1.DisplayLayout.LoadOnDemand = LoadOnDemand.NotSet; this.UltraWebGrid1.DataSource = ds; this.UltraWebGrid1.DataBind();
//Export the data switch (this.Request.QueryString["ExportFormat"].ToString()) { case "Excel": this.UltraWebGridExcelExporter1.Export(this.UltraWebGrid1); break;
}
Thank you for your help!!!
From Edmond
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.