.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

xml to gridview

Posted By: tom.lor.1980     Posted Date: May 22, 2010    Points:2   Category :C#

Hello all!
I'm new to asp.net and i'm trying to bind some XML data to a gridview.
abviously I'm not understanding how to do it properly because that my code doesn't seem to
work...Can anyone could help me please?

this is my xml:
#########################################
<?xml version "1.0" encoding "utf-8"?>
<dictionary>
<item>
<key>
<string> hello world </string>
</key>
<value> <anytype xmlns:q1="http://www.w3.org/2001/XMLSchame" d4p1:type="q1:int"
xmlns:d4p1="http-instance">45</anytype>
</value>
</item>
</dictionary>

and this is my code:
########################################
string path = "D:\\myXmlFile.xml";
DataSet oDs = new DataSet();
oDs.ReadXml(path);
GridView1.DataSource = oDs;
GridView1.DataBind();


thanks
Tom

Responses
Author: Amit Mehra             
Posted Date: May 23, 2010     Points: 5   

hi,

what error you are getting? by seeing your code it should work.


Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Lakhan Pal Garg             
Posted Date: May 24, 2010     Points: 5   

Hi Tom-

If you are getting Blank grid but no exception then thereason is this XML will return more than one table in the Dataset. You can check the output of Dataset using Quick Watch and then bind your Grid According to the Data that you want to show in the grid.

Thanks & Regards
Lakhan Pal Garg

Author: Lalij Mer             
Posted Date: May 24, 2010     Points: 5   


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend