Hi,
I would like to send a GridView to the RadGridReportingLite in order to create a report. Since I need to change the grouping and sorting of the GridView for the report with no effect on the display, I thought of cloning the GridView, send it to the RadGridReportingLite and dispose it.
There is no method of deep copying of the GridView so what I do is:
- Create new GridView.
- Save the layout of the original GridView and load it to the new one.
- Create a copy of the original DataSet (which is the data source of the grid).
- Bind the new DataSet to the new GridView;
- Send the new GridView to the RadGridReportingLite.
The following code snippet demonstrates it.
// Create a new grid for the report.RadGridView grdReport = new RadGridView();// Clone the dataset with the original data.DataSet dsReport = ((DataView)grdOriginal.DataSource).Table.DataSet.Copy();// Set it as the new grid's data source.grdReport.DataSource = dsReport.Tables[0].DefaultView;// Create a stream in the memory.using (MemoryStream stream = new MemoryStream()){ // Save the grid to the stream. grdOriginal.SaveLayout(stream); stream.Seek(0, SeekOrigin.Begin); // Load the original grid layout to the new one. grdReport.LoadLayout(stream);}When I execute this code I get an exception from the RadGridReportingLite, because the GridView is empty. The GridView is never displayed so the binding doesn’t occur. What I’m asking is how do I execute the binding explicitly (something like the DataBind() method in ASP.NET)?
BTW, is there a better way to achieve this functionality?
I’m using 2010 Q1 SP controls.
Thanks in advance,
Sharon.