iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
On a form I have a webGrid that is populated with the WebGrid_InitalizeDataSource event. There is also a button that when the user clicks on will export the data in the Grid to an XML file. The export is being done server side with this line:
When the button is clicked on the above line of code give this error: "Object reference not set to an instance of an object."
If I change the xml to pdf, excel or text, it works. If I click on the Export Grid Icon on the botton of the grid and select XML it works.
Now I have another page with the same setup, except the Gird is bound to an ISDataSource and is Hieracheal and the above line of code works.
So can't I export to an XML file server side without using an ISDataSource, if so how? I am using the server side becuase I need to create the file without streaming it to the user as the file is used for another process behind the scenes.
Thanks
John
Handy,
What I did was to modify the webGrid sample ProgrammaticExportServerSide to use the GenericObject.CustomerDataAccess and created a new GetCustomer function to return a Data Table instead of a list collection. I then modify the Grid to use the same options that my project is using. So this sample now is a bare bones sample of what my project uses, except instead of using Oracle this sample uses Access. I tried to import the Customers table from Access to oracle, but was having trouble.
Now this bare bones sample, works. So it's not the code. So something else is interferring with the proper operation of the ExportGrid. I have no idea where to look and I can't reproduce it outside of my original project. So not sure where to go and what to say.
So I went another route, as this is taking more time than I have. What I am doing is using the ExportGrid method and instead of exporting to XML, I am exporting to a TEXT file and then I wrote a function to take this TEXT file and convert it to XML. That works...
I attached sample about exporting into XML via button. For default, I use 'tempReports' as reportPath. If my sample does not help much, please replicate your issue in my sample and send it back to me. I need it to investigate where i was missing.
Regards,Handy
Using the WebGrid sample ProgrammaticExportServerside.aspx, and modifying the export type to xml, there is no exporting issue. The sample is using AccessDataSource.
Which DataSource did you used to replicate the issue?
Hi Handy and Glenn,
Of sourse your samples work! But mine still doesn't. I don't use a data source control (ISDataSource or ObjectDataSource) . I have a Custom Object where on the WebGrid_Initialize event I set the datasource to a function within the object. I have a button on the form which runs the following code when the user clicks on:
Dim file as stirng = WebGrid1.ExportGrid(ISNet.WebUI.WebGrid.DynARInfo("pdf",Server.MapPath(fn), "fname")
And the PDF file is created, just like your samples. But if I change the line to:
Dim file as stirng = WebGrid1.ExportGrid(ISNet.WebUI.WebGrid.DynARInfo("xml",Server.MapPath(fn), "fname")
I get the following stack trace:
[NullReferenceException: Object reference not set to an instance of an object.] ..(String fileName, Hashtable customAttribute) +385 ..(ActiveReport3 rpt, String reportFileName, Hashtable customAttribute) +561 ..() +370 ISNet.WebUI.WebGrid.WebGrid.ExportGrid(DynARInfo reportInfo) +219
Why would the exact same code work for PDF but not for XML? And the export button on the tray works.
May i know about fn and fname? What value you specify on them? I am afraid that you used incorrect standart. Please ensure also that you give access permission into the path you used.
"fn" is the report path. I don't the TempReports directory, we use a path that is not on the Web and is a virtual directory with all the correct permissions for reading and writing. "fname" is the name of the file, again I don't use the default filename but one that is based upon the logged in users name. I have dropped this variable and used the default name but it also fails. Below is the exact code I use in a Button Event.
Dim fn As String = "/cfxtemp/" Dim fname As String = Page.User.Identity.Name & "_Maps" Dim file As String = WebGrid1.ExportGrid(New ISNet.WebUI.WebGrid.DynARInfo("xml", Server.MapPath(fn), fname))
I agree it may be my programming but why would the exact same code work when exporting to HTML,Text,PDF, Excel, TIFF but only fail for XML?
The only thing that is different between the 2 cases where I use this code, is the one that fails doesn't use anytype of DataSource control, but rather sets the grid datasource in the InitializeDataSource event to a Custom Data Class method and the one that does work uses the ISDataSource server control.
None of your samples bind the grid this way so I can't test to see if it's my coding or the control.
As as workaround (not the best) is just to use the WriteXML method of a DataTable to create my own XML file. As I said this is not the preferred way!
Just wondering if there was anymore on this problem? Why would the exact same code work for every type of export that is supported, except for XML. Does XML export not use the ActiveReports (I noticed there is no XML class in the ActiveReports dll) I see DataDynamics.ActiveReports.Export.HTML, PDF, TIFF, XLS, RTF, TEXT, but no XML.
I need to export from the server side to XML using the ExportGrid method and (I know it works for all the samples), is not working for me!.
I use Oracle and Custom Data Class that returns a DataTable and I set the WebGrid DataSource in the InitializeDataSource event.
I also tested on CustomObject sample without any DataSourceControl and export into default path (it works). If i need to test it on virtual directory, then i need something that similar with your scenario. I have discussed with our developer team and they said only XML does not use ActiveReports engine. So perhaps, you can help me to replicate it in a simple project include step by step. We need it to investigate the issue.
Hi Handy,
I have created a new project that closely matches what I am doing but can't get it to fail. Difference is the test I'm using Access and the orginal using Oracle. I don't know what to say here.
This is realy bizarre. On my page I can export to XML 3 different ways:
1. Using the "Export Grid" button on the WebGrid system tray - NO Problems, file is created
2. Using Client Side script - NO Problems, file is created
3. Using Server Side ExportGrid method - PROBLEMS, file is not created (see stack trace in an message above).
What I want to do is to create an XML file and then open a new window go to a different site and use the XML file as a data source (don't worry how the XML file gets there, these are on the same server so the XML is stored in a virtual directory and is accessible but both sites.)
I could use the Client side export, but I don't want the user to see the XML file as is the case now. Can I turn off the streaming of the export to the browser? Also how can I get the name of the export file client side?
I have tried looking at the ExportCompleted event, but to no avail.
This is driving me crazy and shouldn't be this hard...
Hi John,
Are you really sure if it is using Oracle, I could see the issue while Access has no issue at all?
In fact, we need to replicate the issue first because at this point we could not analyze any of them.
Based on your scenario, client side is not preferrable way. Perhaps, you can send me a simple project (runable) which you have succeed to replicate the issue. This would really help us to investigate your issue.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname