Here I need to download multiple Excel sheets i use for loop. after one iterate loop I got am Exception like below
Server cannot append header after HTTP headers have been sent.
Response.ClearContent();
Response.Buffer = true;
long lnUserID = clsLists.getCurrentUserId();
Response.AddHeader("content-disposition", "attachment; filename=Release-" + ReleaseEMCTSDB.users.SingleOrDefault(u => u.UserId ==
l nUserID).UserName + "-" + DateTime.Now.ToString() + ".xls");
Response.AppendHeader("Name", "Value");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
string readergridview = sw.ToString();
gv.RenderControl(htw);
Response.Output.Write(sw.ToString());
Resp onse.Flush();
Response.End();
}
}
try
{
Exception
}
Please help me it is possible to iterate loop