错误-将xml文件绑定到gridview [英] error --- bind xml file to gridview

查看:73
本文介绍了错误-将xml文件绑定到gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

路径中包含非法字符.

第25行://doc.Load(Server.MapPath("~//xml_file//my_xml.xml));
第26行:doc.Load(@"D:\ my_xml.xml");
第27行:ds.ReadXml(new System.IO.StreamReader(doc.OuterXml));
第28行:GridView1.DataSource = ds;
第29行:GridView1.DataBind();





请帮助我....

我已经尝试了对象的字符串
字符串xmldata = Server.MapPath(〜/")+"my_xml.xml";
doc.Load(xmldata);
ds.ReadXml(new System.IO.StreamReader(doc.OuterXml));
GridView1.DataSource = ds;
GridView1.DataBind();


--------------
但是错误

Illegal characters in path.

Line 25: //doc.Load(Server.MapPath("~//xml_file//my_xml.xml"));
Line 26: doc.Load(@"D:\my_xml.xml");
Line 27: ds.ReadXml(new System.IO.StreamReader(doc.OuterXml));
Line 28: GridView1.DataSource = ds;
Line 29: GridView1.DataBind();





plz help me....

i have try string to object
string xmldata = Server.MapPath("~/") + "my_xml.xml";
doc.Load(xmldata);
ds.ReadXml(new System.IO.StreamReader(doc.OuterXml));
GridView1.DataSource = ds;
GridView1.DataBind();


--------------
but error
Illegal characters in path.

推荐答案

将网格绑定到数据集中的数据表,而不是数据集本身.
GridView1.DataSource = ds.Tables[0];
Bind the grid to the DataTable in the DataSet, not the DataSet itself.
GridView1.DataSource = ds.Tables[0];


这篇关于错误-将xml文件绑定到gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆