Convert datagrid into text file in asp.net
By Super Man
here i will show how you can convert datagrid into textfile:
You can use this code to save datagrid into text file:
code snippet:
StreamWriter sw = new StreamWriter("hello.txt");
foreach(DataGridItem dg in datagrid1.Items)
{
string str = string.Empty;
for (int i = 0; i < dg.Cells.Count; i++)
{
str
+= dg.Cells[i].Text + " ";
}
sw.WriteLine(str);
}
sw.Close();
Convert datagrid into text file in asp.net (434 Views)