Last post Dec 08, 2010 08:53 AM by CodingMB
Dec 07, 2010 12:11 PM|CodingMB|LINK
I am currently struggling with the following task.
I have a common Linq/DD project, a simple SQL DB frontend with only 2 linked tables. I also injected custom filters but everything else ist quite default (no custom pages etc.). Everything looks good so far and the filtering works like a charm. What I am
now trying to achieve is the export of the filtered data to a csv file. For this I found a LINQ2CSV class that also works quite well and I have tested it with normal LINQ queries, no problem.
The problem starts when I am trying to find a way to get the full (unpaged) data or the query that is the source of the currently displayed data in the gridview. Filtering is done by QueryExtender, DynamicFilterExpression and QueryableFilterRepeater (all
default) and it is sooooo dynamic that I am not able to find en entry point where i could get my desired data. I have already tried:
GridDataSource_Selected: paged data (but full filtered result count)
GridDataSource_Selecting: empty (only arguments like page size)
GridDataSource_QueryCreated: unfiltered data
I also had a look at the other controls and their events but nowhere is a sign of any query string or where parameters at all.
Has someone an idea where I could get either the complete filtered data (IEnumerator, List, whatever) or is there another/better way to export the full filtered data currently display in a gridview (without the need of defining table specific values, I
would like to keep it as dynamic as possible so I can expand the project without to much effort).
Export to Excel
Dec 07, 2010 03:19 PM|sjnaughton|LINK
Hi CodingMB, have tried turning paging off before you export? I have sucessfully using this with export to Excel.
Dynamic Data 4
Dec 07, 2010 05:05 PM|CodingMB|LINK
Thanks for the response, it's indeed the right direction.... but how do you manage to force the refresh/databind/refill (or how you call it) of the gridview before the postback auf the 'generate csv' button?
When I set AllowPaging to false within the click event of the button, the gridview will not be 'refilled' until the click event completes. And gridview.databind ends up filling the gridview with the wrong data (unfiltered) so this is neither an option.
I hope I'm not overseeing something obvious.
Dec 08, 2010 08:29 AM|sjnaughton|LINK
For my sample I simply added a checkbox with postback and simply toggled paging on the gridview based on the check box and ley the user do it.
Dec 08, 2010 08:53 AM|CodingMB|LINK
I found a solution that works for me:
With the export link button I just switch paging an set a flag value in the viewstate. This causes a postback und I jump in again at the GridDataSource_Selected event, where I check for my flag and if set, make my export and set paging again to the original
The important hint was the paging, so thanks a lot for that.