create a relation betweeen 2 tables in a dataview

Aug 10 2005 7:28 AM

Hi

I have added a Datagrid to a form , and a button is added .
I have programmed in such a way that when the button is clicked,
from reading 2 xml files, and developing a relation between 2 tables and show it in the grid.

and that part of my program is as follows

DataSet ds = new DataSet();
DataSet xml1 = new DataSet();
xml1.ReadXml("C:\\CDEV\\Relation\\cost_code.xml");
DataTable dt1 = xml1.Tables["cost_code"].Copy();

DataSet xml2 = new DataSet();
xml2.ReadXml("C:\\CDEV\\Relation\\cost_type.xml");
DataTable dt2 = xml2.Tables["cost_type1"].Copy();

ds.Tables.Add(dt1);
ds.Tables.Add(dt2);

DataColumn parentCol = ds.Tables["cost_type1"].Columns["cost_type"];
DataColumn childCol = ds.Tables["cost_code"].Columns["cost_type"];
DataRelation relTable1Table2;
relTable1Table2 = new DataRelation("cost_typecost_code", parentCol, childCol);
ds.Relations.Add(relTable1Table2);

dataGrid1.DataSource = ds;

now what I need is that , i have to give the dataview not the dataset.
I am not familiar with the datview.so pls anyone explain to meor change the coding part and explain .

j o h n


Answers (2)