By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,637 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,637 IT Pros & Developers. It's quick & easy.

Binding and Editing XML Data (Urgent)

P: 3
Hi,

Please help me as soon as possible for the following problem. It is very very urgent.

I have an XML file as follows:

<?xml version="1.0" standalone="yes"?>
<Employee>
<em name="Asha" id="1">
<details>456</details>
<details>897</details>
</em>
<em name="Siva" id="2">
<details>890</details>
<details>234</details>
</em>
<em name="Lekshmi" id="3">
<details>3768</details>
<details>777</details>
</em>
....

....

....

</Employee>



I am unable to bind these data in GridView.

Please help me to bind and edit these XML data using GridView Control or Repeater Control.

It is very urgent.


Thanks in Advance,

Regards,

Asha Sivan
Aug 10 '07 #1
Share this Question
Share on Google+
4 Replies


dip_developer
Expert 100+
P: 648
Hi,

Please help me as soon as possible for the following problem. It is very very urgent.

I have an XML file as follows:

<?xml version="1.0" standalone="yes"?>
<Employee>
<em name="Asha" id="1">
<details>456</details>
<details>897</details>
</em>
<em name="Siva" id="2">
<details>890</details>
<details>234</details>
</em>
<em name="Lekshmi" id="3">
<details>3768</details>
<details>777</details>
</em>
....

....

....

</Employee>



I am unable to bind these data in GridView.

Please help me to bind and edit these XML data using GridView Control or Repeater Control.

It is very urgent.


Thanks in Advance,

Regards,

Asha Sivan
convert your xml to a DataSet.....then bind DataSet with your DataGrid or GridView...

try this..............

Expand|Select|Wrap|Line Numbers
  1.  
  2. string myXMLfile = @"C:\myXMLFileName.xml";
  3.     DataSet ds = new DataSet();
  4.     // Create new FileStream with which to read the schema.
  5.     System.IO.FileStream fsReadXml = new System.IO.FileStream 
  6.         (myXMLfile, System.IO.FileMode.Open);
  7.     try
  8.     {
  9.         // Bind datagrid with dataset or gridview
  10.  
  11.         ds.ReadXml(fsReadXml);
  12.         dataGrid1.DataSource = ds;
  13.         dataGrid1.DataMember = "Cust";
  14.     }
  15.     catch (Exception ex)
  16.     {
  17.  MessageBox.Show(ex.ToString());
  18.     }
  19.     finally
  20.     {
  21.  fsReadXml.Close();
  22.     }
  23.  
Aug 10 '07 #2

P: 3
Thanks for your reply.
Actually I want to edit the data also and it should be in ASP.NET.. not in C#
Aug 10 '07 #3

dip_developer
Expert 100+
P: 648
Thanks for your reply.
Actually I want to edit the data also and it should be in ASP.NET.. not in C#
Two things I have to say....
1.Firstly...you can make this datagrid editable......
look here...
http://www.megasolutions.net/kb/Edit..._DatagRid.aspx

2. secondly what do you mean by
it should be in ASP.NET.. not in C#??

do you know what you are saying actually????

ASP.net is a platform by which you can make an Application with an web user interface.......this application can be created with any language like vb/c#/j#...........I have written the code in C#.net......its my choice......you may write your code in vb.net.....but in any way the application is an ASP.net application.......

then what is the meaning of
it should be in ASP.NET.. not in C#??
Aug 10 '07 #4

P: 3
I mean that I doing a web application. So the gridview control from asp.net have to use. Not for the windows application.

And also I know that GridView can be made editable. My problem is if I am having same tag then I am unable to bind it.

<?xml version="1.0" standalone="yes"?>
<Employee>
<em name="Asha" id="1">
<details>456</details>
<details>897</details>
</em>
<em name="Siva" id="2">
<details>890</details>
<details>234</details>
</em>
<em name="Lekshmi" id="3">
<details>3768</details>
<details>777</details>
</em>
....

....

....

</Employee>

here in this file there are more than 1 details tag. If it is only one is there, I am able to bind and edit data. But the problem is more than 1 tag with same name.


I think you understand my problem.

Asha Sivan
Aug 10 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.