954,153 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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:

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

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

Mapper99
Light Poster
42 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

What are you wanting then?

Are you wanting the data or gridview to be written?

Also you are using htmltextwriter, which is exporting html.

dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
 

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?

Mapper99
Light Poster
42 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

Use the DataSet.WriteXml method.

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

dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
 

Yes i also find that how to export data from gridview to XML file

After lot of searching i founding at Export Data from Gridview to XML

Hope you enjoy...

hello2222
Newbie Poster
1 post since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You