Click here to Skip to main content
15,914,924 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi friends i have a datagridview1 in that i have rows with event id's if you click on the id then you have to display the data from xml file with the help of dataset and display it in another datagridview2.now i want to get the data from xml tag attribute value and put it in dataset and then when we click on the eventid then with respect to that id we have display the data in datagridview2 and i have id's attached to every node in xml
pls any ideas.........

What I have tried:

C#
XDocument doc = XDocument.Load("xml1.xml");

var items = doc.Descendants("Table3")
               .Where(node => (string)node.Attribute("ID") == "ID")
               .Select(node => node.Value.ToString())
               .ToList();

label9.Text = items.ToString();

foreach (DataTable dt in ds.Tables)
{
	foreach (DataRow dr in dt.Rows)
	{
		string str=dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
		dataGridView2.Rows[row1].Cells[cell1].Value = ds.Tables[3].Rows[row1][cell1];
		cell1++;

		if (cell1 == 13)
		{
			row1++;
			cell1 = 0;
			dataGridView2.Rows.Add();
		}
	}
}

xml data also:
XML
  <?xml version="1.0" standalone="yes" ?> 
- <xmldoc>
  <Events /> 
- <Table1 ID="71029">
  <parts>1 
  <at1status>Completed 
  <writer>chai 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>Santhos 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>Sri 
  <qstartist>6:00 
  <qendist>7:00 
  <qc.status>Started 
  
- <table1>
  <parts>2 
  <at1status>Completed 
  <writer>chal 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>sanu 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>ram 
  <qstartist>8;00 
  <qendist>8:00 
  <qc.status>Completed 
  
- <table1>
  <parts>3 
  <at1status>Completed 
  <writer>ch.sri 
  <startist>8:00 
  <endist>9:00 
  <wr.status>Not_Started 
  <editor>sar 
  <estartist>9:00 
  <eendist>10:00 
  <ed.status>Not_Started 
  <qc>ram 
  <qstartist>9:00 
  <qendist>8:00 
  <qc.status>Completed 
  
  <Table1 /> 
- <Table2 ID="71030">
  <parts>1 
  <at1status>Completed 
  <writer>chai 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Completed 
  <editor>chau 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>tar 
  <qstartist>9:00 
  <qendist>10:00 
  <qc.status>Not_Started 
  
- <table2>
  <parts>2 
  <at1status>Completed 
  <writer>chari 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>hali 
  <estartist>9:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>rant 
  <qstartist>9:00 
  <qendist>11:00 
  <qc.status>Not_Started 
  
  <Table2 /> 
- <Table3 ID="71031">
  <parts>1 
  <at1status>Completed 
  <writer>chan 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>sam 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>sanu 
  <qstartist>7:00 
  <qendist>8:00 
  <qc.status>Completed 
  
- <table3>
  <parts>2 
  <at1status>Not_Started 
  <writer>hali 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>sar 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>gahi 
  <qstartist>8:00 
  <qendist>9:00 
  <qc.status>Completed 
  
  <Table3 /> 
- <Table4 ID="71032">
  <parts>1 
  <at1status>Completed 
  <writer>chani 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>mas 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>sanu 
  <qstartist>7:00 
  <qendist>8:00 
  <qc.status>Completed 
  
- <table4>
  <parts>2 
  <at1status>Not_Started 
  <writer>halihali 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>esar 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>gahi 
  <qstartist>8:00 
  <qendist>9:00 
  <qc.status>Completed 
  
- <table4>
  <parts>3 
  <at1status>Not_Started 
  <writer>ali 
  <startist>9:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>ras 
  <estartist>9:00 
  <eendist>9:30 
  <ed.status>Not_Started 
  <qc>haf 
  <qstartist>9:00 
  <qendist>10:00 
  <qc.status>Completed 
  
  <Table4 /> 
- <Table5 ID="71033">
  <parts>1 
  <at1status>Completed 
  <writer>iahc 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>sohtnas 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>irs 
  <qstartist>6:00 
  <qendist>7:00 
  <qc.status>Completed 
  
- <table5>
  <parts>2 
  <at1status>Completed 
  <writer>haweye 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>hosath 
  <estartist>9:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>ris 
  <qstartist>7:00 
  <qendist>8:00 
  <qc.status>Completed 
  
  <Table5 /> 
- <Table6 ID="71034">
  <parts>1 
  <at1status>Completed 
  <writer>aihc 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>thanos 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>savin 
  <qstartist>6:00 
  <qendist>7:00 
  <qc.status>Not_Started 
  
- <table6>
  <parts>2 
  <at1status>Completed 
  <writer>chal 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Completed 
  <editor>nostha 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>nivas 
  <qstartist>7;00 
  <qendist>8;00 
  <qc.status>Completed 
  
  <Table6 /> 
- <Table7 ID="71035">
  <parts>1 
  <at1status>Completed 
  <writer>haic 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>hostahs 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>nisa 
  <qstartist>6:00 
  <qendist>7:00 
  <qc.status>Completed 
  
- <table7>
  <parts>2 
  <at1status>Completed 
  <writer>chal 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>nusan 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>hija 
  <qstartist>7:00 
  <qendist>8:00 
  <qc.status>Completed 
  
  <Table7 /> 
- <Table8 ID="71036">
  <parts>1 
  <at1status>Completed 
  <writer>ajay 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>emily 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>ben 
  <qstartist>6:00 
  <qendist>7:00 
  <qc.status>Completed 
  
- <table8>
  <parts>2 
  <at1status>Completed 
  <writer>bing 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>chandler 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>joey 
  <qstartist>8:00 
  <qendist>9:00 
  <qc.status>Completed 
  
  <Table8 /> 
- <Table9 ID="71037">
  <parts>1 
  <at1status>Completed 
  <writer>raichu 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>phikar 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>razid 
  <qstartist>6:00 
  <qendist>7:00 
  <qc.status>Completed 
  
- <table9>
  <parts>2 
  <at1status>Completed 
  <writer>chal 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>anus 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>sam 
  <qstartist>8;00 
  <qendist>8:00 
  <qc.status>Completed 
  
- <table9>
  <parts>3 
  <at1status>Not_Started 
  <writer>hanu 
  <startist>8;00 
  <endist>9:00 
  <wr.status>Not_Started 
  <editor>sanhu 
  <estartist>9:00 
  <eendist>10:00 
  <ed.status>Not_Started 
  <qc>manu 
  <qstartist>9;00 
  <qendist>10:00 
  <qc.status>Completed 
  
  <Table9 /> 
- <Table10 ID="71038">
  <parts>1 
  <at1status>Completed 
  <writer>chai 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>Santhos 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>Sri 
  <qstartist>6:00 
  <qendist>7:00 
  <qc.status>Completed 
  
- <table10>
  <parts>2 
  <at1status>Completed 
  <writer>chal 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>sanu 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>ram 
  <qstartist>8;00 
  <qendist>8:00 
  <qc.status>Completed 
  
- <table10>
  <parts>3 
  <at1status>Completed 
  <writer>ch.sri 
  <startist>8:00 
  <endist>9:00 
  <wr.status>Completed 
  <editor>srini 
  <estartist>9:00 
  <eendist>10:00 
  <ed.status>Not_Started 
  <qc>arm 
  <qstartist>9:00 
  <qendist>9:00 
  <qc.status>Completed 
  
  <Table10 /> 
- <table11>
  <parts>1 
  <at1status>Completed 
  <writer>key2 
  <startist>6:00 
  <endist>7:00 
  <wr.status>Not_Started 
  <editor>yahi 
  <estartist>7:00 
  <eendist>8:00 
  <ed.status>Not_Started 
  <qc>yash 
  <qstartist>6:00 
  <qendist>7:00 
  
- <table11>
  <parts>2 
  <at1status>Completed 
  <writer>lachmi 
  <startist>7:00 
  <endist>8:00 
  <wr.status>Not_Started 
  <editor>cam 
  <estartist>8:00 
  <eendist>9:00 
  <ed.status>Not_Started 
  <qc>ram 
  <qstartist>8;00 
  <qendist>8:00 
  
- <table11>
  <parts>3 
  <at1status>Completed 
  <writer>ch.sri 
  <startist>8:00 
  <endist>9:00 
  <wr.status>Not_Started 
  <editor>sar 
  <estartist>9:00 
  <eendist>10:00 
  <ed.status>Completed 
  <qc>puneeth 
  <qstartist>9:00 
  <qendist>10:00 
  <qc.status>Completed 
  
  <Table11 />
Posted
Updated 8-Sep-17 3:31am
v4
Comments
Graeme_Grant 8-Sep-17 8:10am    
Your XML is invalid... missing closing tags. This needs to be fixed before you can do what you want.
Member 13375990 8-Sep-17 9:24am    
it is not invalid i just posted half of the code because website not supporting full code to fast my upload i posted small code @graeme_grant
Graeme_Grant 8-Sep-17 9:28am    
<writer>chai - missing closing tag, should be <writer>chai</writer>; <Table1 /> - not a closing tag, it is an empty element and should be </Table1>

So yes, invalid XML. If you doubt my answer, then here is a link to the official documentation for the XML Specification[^]

Remember, you are asking for OUR help, it pays to listen.
Graeme_Grant 8-Sep-17 9:31am    
Please use correct formatting - corrected again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900