Adding "Export to XML" to Dynamic Data Site

Go To StackoverFlow.com

0

Am working on a business layer for a complex web application and am temporary using the Dynamic Data Site functionality to allow data to be entered into the many tables that I need to maintain. I don't want to spend too much time on this DDS since the business layer needs to be finished first. Once the business layer is done, it gets shipped to someone else to add a better user interface.

However, while the DDS offers a lot of functionality in a very easy way, I just want to extend it with an "Export to XML" button or link. (And I'll probably will add an "Export to Excel" button later.)

So, has anyone done something like this already? What would be the easiest way to implement this in .NET, without rewriting the DDS?

(I use an Entity model for the database connection and much of the business layer is built upon this entity model. Once the business layer is finished, the real GUI interface will be developed for this web application but for now I just need a good way to input/output this data.)


I have no problems converting an entity set to XML. That's the easy part. My problem lies in expanding "ListDetails.aspx" with an additional button which the user can click. Once clicked, it should export the dataset to XML. To make it interesting, if the user has set one or more filters, it should only export those filtered records. I think I'll have to look into the "GridDataSource" object that's on this page and experiment with it. Will it return the whole table or just the filtered dataset? Or just the records that are on the current page?


Now, with export, I just want a dump of the dataset to XML. Basically, what you see should end up in the final XML. If I have access to the filtered dataset then creating the XML would be easy. (And creating the Excel sheet on top of that is a piece of cake too.) In general, the export is just used to help develop the business layer of a project I'm working on. Most of the code is business logic that will be used in other (web/desktop) client applications but while the project is still in progress, the DDS is needed for easier data entry for the project. Once it's finished (a gazillion years from now, I guess) then the DDS won't be used anymore. Nor would we use the XML exports or the export sheets. But for now, those exports are useful to evaluate the data. (Since I still have to develop the more complex analysis tools.)

2009-06-16 09:14
by Wim ten Brink
Ah, that is a much more interesting (and far less generic question). You still haven't defined "export" though. Irritatingly I have day job to do - Murph 2009-06-18 09:23
Export isn't difficult. Just the filtered dataset itself, nothing more. I can do the XML stuff myself but my problem is finding access to the filtered dataset that's used to set up the page - Wim ten Brink 2009-06-18 10:46


0

This is fairly straightforward, you've got to address a couple of issues:

  • Providing a means to trigger the export
  • Generating the XML
  • Making the XML available (as a link) for download - assuming that that's what you want to do.

There's a slightly less straightforward alternative which is to create a service to generate and return the XML.

In terms of the first - there's nothing to stop you editing either the master page or the default page to add your own functionaliy i.e. a button or a link to an XML gen page.

In terms of the second - Linq makes it almost trivial to generate XML from your Entity model.

Once you've got your XML you've got various options the key here is that you can add your own pages to the site if you want - the magic in Dynamic Data is simply a starting point not the final product (although if it does all you need then you can walk away with a smile on your face).

I appreciate that these are generic answers but its a fairly generic question and the details of implementation would be better addressed by more specific pages.

In terms of specific, I have a Dyanmic data site which needs to generate XML, the first iteration was simply a button on the default page that saved a file to disk (one file name, one file format, click, gen, save, done). The reason for the XML was as the source data for another site so I then added a WCF service which exposes the same XML. Total time spent (less a bit for getting my head around WCF) probably less than half a day - most of which has been spent fiddling with the XML output.

2009-06-18 08:13
by Murph
I don't get how this answers the question. "Linq makes it almost trivial"? Awesome. HOW - Mike K 2010-09-22 17:19
Just out of curiosity, what do you know about a) dynamic data and b) Linq - Murph 2010-09-22 18:26


0

Maybe you can do something with FileHelpers.

2009-06-18 07:49
by bob