0
2312345678445008
2312345678445000
Response.ClearContent(); Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.csv")); Response.ContentType = "application/text"; //GridView1.AllowPaging = false; //GridView1.DataBind(); StringBuilder strbldr = new StringBuilder(); for (int i = 0; i < GridView1.Columns.Count; i++) { //separting header columns text with comma operator strbldr.Append(GridView1.Columns[i].HeaderText + ','); } //appending new line for gridview header row strbldr.Append("\n"); for (int j = 0; j < GridView1.Rows.Count; j++) { for (int k = 0; k < GridView1.Columns.Count; k++) { //separating gridview columns with comma strbldr.Append(GridView1.Rows[j].Cells[k].Text + ','); } //appending new line for gridview rows strbldr.Append("\n"); } Response.Write(strbldr.ToString()); Response.End();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)