Vikas Ahlawat

Vikas Ahlawat

  • NA
  • 564
  • 808.8k

XML read Problem.

Jul 14 2011 3:33 AM
Hi
I have an XML. I want to bind its data to gridview

XML format is

<Upload>
  <CategoryName ID="Vikas">
    <Imagepath>Chrysanthemum.jpg</Imagepath>
    <Imagepath>Jellyfish.jpg</Imagepath>
    <Imagepath>Koala.jpg</Imagepath>
  </CategoryName>
  <CategoryName ID="naveen">
    <Imagepath>Jellyfish.jpg</Imagepath>
    <Imagepath>Tulips.jpg</Imagepath>
    <Imagepath>Chrysanthemum.jpg</Imagepath>
  </CategoryName>
</Upload>


When I use
ds.ReadXml(xmlPath);
Then in dataset I got two tables
With the names "CategoryName" and "ImagePath"
"CategoryName" table have two columns "categoryName_Id", and "categoryName_Text"
"ImagePath" table have also two columns "categoryName_Id", and "ImagePath_Text"

Now how can I bind these tables to gridview. I want to bind Categoryname_text and Imagepath.
How can i do this.
When i try to join these tables using below method
http://social.msdn.microsoft.com/forums/en-US/adodotnetdataproviders/thread/f122d7f4-3b7d-4d93-bd0f-8bb57cd990a4/

DataRelation datarlt = new DataRelation("EquiJoin",ds.Tables["CategoryName"].Columns["CategoryName_Id"],ds.Tables["ImagePath"].Columns["CategoryName_Id"]);
        ds.Relations.Add(datarlt);
for this when i try to create relation then its says that relation already exist.

is there any simple solution of my problem?

Answers (2)