I am populating a WebDataGrid dynamically. The data is complex and created dynamically in memory and placed in a DataTable. When I assign the data grid's datasource to the table the data appears correctly in the grid. The grid's AutoGenerateColumns="true".
When I export the grid to Excel I just get the column headings with no data. DataExportMode is AllDataInDataSource.
Help!
IG 11.1 Version=11.1.20111.1006
Hello PaulShearing,
Thank you for posting this question in our community. Here I am attaching a sample demonstrating how to expert a WebDataGrid. I am populating the data in the grid, binding it to a DataTable.
I hope this helps.
For any further questions do not hesitate to contact me.
Sincerely,
Georgi Sashev
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Georgi,
Thank you for taking the time to reply in such a comprehensive manner - very much appreciated. It has worked inasmuch as it proved to me that it is possible. I have spent quite a while trying to ascertain why your example worked and mine didn't.
It turns out to be a data persistence issue. In your example, you rebuild the datasource and assign it to the grid every time there is a postback and when the page is first loaded. If you modify the Page Load procedure such that it builds and assigns the data source only when the page is first loaded you will get the same behaviour that I was getting.
The answer is to add the attributes: EnableViewState="true" EnableDataViewState="true" to the data grid. This preserves the data across postbacks (albeit at the expense of a much larger ViewState) and allows the Exporter to see the data in the grid. What was throwing me was that data was still visible in the grid even though the underlying datasource was no longer available.
Thanks again
Paul
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
Hello Paul,
Thank you for the feedback.
For any further questions do note hesitate to contact me.