3
Reply

Notepad c# txt Design

Manoj Maharana

Manoj Maharana

Aug 12 2016 1:45 AM
262
I want to show all the data horiozantally in a txt file 
Problem is that all the data are overlap
I want to show txt format in
xyz:...
pqr:...
.......................
 
 
just like
 
I have taken all the data in a datatable here:
dtRecords.Rows.Add(obj);
 
 
 
 
//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?? 
 

Answers (3)