xyz:...
pqr:...
.......................
//Build the Text file data.
string txt = string.Empty;
foreach (DataColumn column in dtRecords.Columns)
{
//Add the Header row for Text file.
txt += column.ColumnName + "\t\t";
}
//Add new line.
txt += "\r\n";
foreach (DataRow row in dtRecords.Rows)
{
foreach (DataColumn column in dtRecords.Columns)
{
//Add the Data rows.
txt += row[column.ColumnName].ToString() + "\t\t";
}
//Add new line.
txt += "\r\n";
}
//Download the Text file.
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=SqlExport.txt");
Response.Charset = "";
Response.ContentType = "application/text";
Response.Output.Write(txt);
Response.Flush();
Response.End();
Can anyone guide me how to do??