You could try something of this kind.
DataGridItemCollection dgItem1 = DataGrid1.Items;
DataGridItemCollection dgItem2 = DataGrid2.Items;
DataGridItemCollection dgItem3 = DataGrid3.Items;
System.IO.FileStream f = new
System.IO.FileStream("c:\\Text1.csv",System.IO.FileMode.OpenOrCreate,System.
IO.FileAccess.Write);
System.IO.StreamWriter sr = new System.IO.StreamWriter(f);
string strOutput = "";
strOutput = "";
strOutput = strOutput + DataGrid1.Columns[1].HeaderText + ",";
sr.WriteLine(strOutput);
foreach(DataGridItem dgi1 in dgItem1)
{
strOutput = "";
strOutput = dgi1.Cells[0].Text + ",";
strOutput = strOutput + dgi1.Cells[1].Text ;
sr.WriteLine(strOutput);
}
foreach(DataGridItem dgi2 in dgItem2)
{
strOutput = "";
strOutput = dgi2.Cells[0].Text + ",";
strOutput = strOutput + dgi2.Cells[1].Text ;
sr.WriteLine(strOutput);
}
foreach(DataGridItem dgi3 in dgItem3)
{
strOutput = "";
strOutput = dgi3.Cells[0].Text + ",";
strOutput = strOutput + dg3i.Cells[1].Text ;
sr.WriteLine(strOutput);
}
sr.Close();
Regards,
--
Tarkeshwar
..Net Programmer
Fifth Generation Technologies
Hitesh said:
Hi,
I have three datagrid control on my aspx page and one export to excel
button, i want to export all the 3 datagrids contents in one excel
file.
how