问题描述
大家好,
我在VS2010中有一个网页,其中有一个gridview显示来自sql表的数据。它还有一个按钮。我希望按钮能够运行代码,将表数据导出到XML文件。
I have a webpage in VS2010 that has a gridview showing data from a sql table. It also has a button. I want the button to be able to run code behind that will export the table data to an XML file.
我可以使用MS中的查询执行此操作,但它不包含XML声明或将结果作为XML保存到指定位置。
I can do this with a query in MS but it doesnt include the XML declaration or save the result as an XML to a specified location.
我查看了XMLDocument,XmlTextWriter,但这些似乎不对。
I have looked at XMLDocument, XmlTextWriter but these don't seem right.
请帮助...
最佳
Lee
Lee Warren
Lee Warren
推荐答案
以下是否有帮助?你可以发布一些代码如何绑定gridview。
Will the below help ? can you post some code how you are binding gridview .
DataTable objTable = yourgridview.DataSource as DataTable;
objTable.WriteXml(" filename.xml") ;
DataTable objTable = yourgridview.DataSource as DataTable;
objTable.WriteXml("filename.xml");
谢谢你b $ b
这篇关于如何:通过C#将数据集从sql表导出到XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!