R
Raj Chudasama
I am trying to read an xml file and have it view data in the datagrid. (For
example take the xml file viewer in the visual studio, when u open an xml
file it has that nice readable grid).
I though that when i use the ReadXml funtion it will automatically read data
and add the data to the datagrid.
but i am wrong its not that simple. so i need help only with adding the data
to the datagrid.
this is what i have so far. I have created the grid with coulum names now i
need to add the rows of data. please help me thanks
private void CreateDataSet(string fileName)
{
DataSet newDataSet = new DataSet("New Data Set");
System.IO.FileStream readXml = new
System.IO.FileStream(fileName,System.IO.FileMode.Open);
newDataSet.ReadXml(readXml);
readXml.Close();
DataTable myTable = new DataTable("Mytable");
DataColumn cl1 = new DataColumn("Date");
DataColumn cl2 = new DataColumn("Device");
DataColumn cl3 = new DataColumn("call id");
DataColumn cl4 = new DataColumn("source");
DataColumn cl5 = new DataColumn("destination");
myTable.Columns.Add(cl1);
myTable.Columns.Add(cl2);
myTable.Columns.Add(cl3);
myTable.Columns.Add(cl4);
myTable.Columns.Add(cl5);
////////////// ADD ROWS HERE??????????////////
newDataSet.Tables.Add(myTable);
dataGrid1.SetDataBinding(newDataSet,"Mytable");
}
example take the xml file viewer in the visual studio, when u open an xml
file it has that nice readable grid).
I though that when i use the ReadXml funtion it will automatically read data
and add the data to the datagrid.
but i am wrong its not that simple. so i need help only with adding the data
to the datagrid.
this is what i have so far. I have created the grid with coulum names now i
need to add the rows of data. please help me thanks
private void CreateDataSet(string fileName)
{
DataSet newDataSet = new DataSet("New Data Set");
System.IO.FileStream readXml = new
System.IO.FileStream(fileName,System.IO.FileMode.Open);
newDataSet.ReadXml(readXml);
readXml.Close();
DataTable myTable = new DataTable("Mytable");
DataColumn cl1 = new DataColumn("Date");
DataColumn cl2 = new DataColumn("Device");
DataColumn cl3 = new DataColumn("call id");
DataColumn cl4 = new DataColumn("source");
DataColumn cl5 = new DataColumn("destination");
myTable.Columns.Add(cl1);
myTable.Columns.Add(cl2);
myTable.Columns.Add(cl3);
myTable.Columns.Add(cl4);
myTable.Columns.Add(cl5);
////////////// ADD ROWS HERE??????????////////
newDataSet.Tables.Add(myTable);
dataGrid1.SetDataBinding(newDataSet,"Mytable");
}