I Think this will useful to u . . .
protected void btnExport_Click(object sender, EventArgs e)
{
btnView_Click(sender, e);
Response.ClearContent();
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "FileName.csv"));
Response.ContentType = "application/text";
grdSell.AllowPaging = false;
grdSell.DataBind();
StringBuilder strbldr = new StringBuilder();
for (int i = 0; i < grdSell.Columns.Count; i++)
{
strbldr.Append(grdSell.Columns[i].HeaderText + ',');
}
strbldr.Append("\n");
for (int j = 0; j < grdSell.Rows.Count; j++)
{
for (int k = 0; k < grdSell.Columns.Count; k++)
{
strbldr.Append(grdSell.Rows[j].Cells[k].Text + ',');
}
strbldr.Append("\n");
}
Response.Write(strbldr.ToString());
Response.End();
}