Hello I have a question when reading an xml file and visualize the information in two datagridview. My intention is to read a file that contains information about several metro lines (class 1) where each subway line has different stations (class 2) by entering that information in a dataset. For this I have implemented the following code:
LinesDataSet.ReadXml(filePath);
dataGridView1.DataSource = LinesDataSet.Tables["CLinia"];
In this way I have a datagridview with the information of the lines (where each column is an attribute of that class and each row is a different line).
Later I want that when clicking on a row of this datagridview the stations corresponding to the selected line in another datagridview are displayed. For this I have implemented the following code:
dataGridView2.DataSource = LinesDataSet.Tables["CEstacio"];
The problem I have is that when clicking, all the stations are displayed (of all the lines) and I only want the stations of the selected line to be displayed. How could I manage the dataset to achieve that? I do not know how to access the stations of only one line. The format of the xml file is as follows:
<ArrayOfCLinia xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CLinia>
<estacions>
<CEstacio>
<CodiEstacio>e1</CodiEstacio>
<Nom>Fondo</Nom>
<Posicio>
<double>21.33</double>
<double>33.43</double>
</Posicio>
<Tipus>baixador</Tipus>
<Ordre>1</Ordre>
</CEstacio>
<CEstacio>
<CodiEstacio>e2</CodiEstacio>
<Nom>Fabra i Puig</Nom>
<Posicio>
<double>21.33</double>
<double>33.43</double>
</Posicio>
<Tipus>baixador</Tipus>
<Ordre>2</Ordre>
</CEstacio>
</estacions>
<Codi>L1</Codi>
<Descripcio>Fondo-Hospital</Descripcio>
<Acronim>linia 1</Acronim>
</CLinia>
<CLinia>
<estacions>
<CEstacio>
<CodiEstacio>e1</CodiEstacio>
<Nom>Hospital</Nom>
<Posicio>
<double>21.33</double>
<double>33.43</double>
</Posicio>
<Tipus>baixador</Tipus>
<Ordre>1</Ordre>
</CEstacio>
<CEstacio>
<CodiEstacio>e2</CodiEstacio>
<Nom>Sagrera</Nom>
<Posicio>
<double>21.33</double>
<double>33.43</double>
</Posicio>
<Tipus>estacio</Tipus>
<Ordre>2</Ordre>
</CEstacio>
</estacions>
<Codi>L2</Codi>
<Descripcio>Sagrera-Navas</Descripcio>
<Acronim>linia 2</Acronim>
</CLinia>
</ArrayOfCLinia>
Thank you very much in advance.