DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Gridview Export to XML not formatting tags correctly.. (http://www.daniweb.com/forums/thread153144.html)

Mapper99 Oct 23rd, 2008 4:34 pm
Gridview Export to XML not formatting tags correctly..
 
I have some code which exports the contents of a gridview to XML. The XML is coming out with incorrect field tags:

<tr>
<td>Builder Damage Inspection</td>
<td>request for final BDI inspection. No damage report on pre damage inspection.</td>
<td>2008-07-09 3:13:59 PM</td>
<td>2008-08-13 9:13:48 AM</td>
<td>512135</td>
<td>5450865</td>
<td>CLOSED</td>
</tr>

Here is the code I am using to do the export:
Response.ClearContent()
Response.AddHeader("content-disposition", "attachment; filename=test.xml")
Response.ContentType = "text/xml"
Dim oStringWriter As New IO.StringWriter()
Dim oHtmlTextWriter As New HtmlTextWriter(oStringWriter)
GridView1.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString)
Response.End()

Am I taking the correct approach with this?

Thanks in advance,

M

dickersonka Oct 27th, 2008 4:47 pm
Re: Gridview Export to XML not formatting tags correctly..
 
What are you wanting then?

Are you wanting the data or gridview to be written?

Also you are using htmltextwriter, which is exporting html.

Mapper99 Oct 27th, 2008 5:43 pm
Re: Gridview Export to XML not formatting tags correctly..
 
Thanks for your reply. I would like the data, not the html. Do you have a suggestion on how to export the output of a SQL data source instead?

dickersonka Oct 27th, 2008 6:07 pm
Re: Gridview Export to XML not formatting tags correctly..
 
Use the DataSet.WriteXml method.

Post the code you have where you set the datasource if you are having trouble still.


All times are GMT -4. The time now is 5:39 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC