HI i'm trying to get a datagrid to export to a csv. Code is below but all I get is a blank CSV. Can anyone please point me in the right direction??
//seperate datagrid to comma seperated values
string strRowVal = "";
foreach (DataGridItem item in layoutsGrid.Items)
{
string str = "";
for (int i = 0; i < item.Cells.Count; i++)
{
str += item.Cells.Text + ",";
}
str = str.Substring(0, str.Length - 1);
}
//append to csv file
StreamWriter sw = File.AppendText("e:\\results\\decdiy.csv");
{
sw.WriteLine(strRowVal);
}
sw.Close();
//seperate datagrid to comma seperated values
string strRowVal = "";
foreach (DataGridItem item in layoutsGrid.Items)
{
string str = "";
for (int i = 0; i < item.Cells.Count; i++)
{
str += item.Cells.Text + ",";
}
str = str.Substring(0, str.Length - 1);
}
//append to csv file
StreamWriter sw = File.AppendText("e:\\results\\decdiy.csv");
{
sw.WriteLine(strRowVal);
}
sw.Close();