Hi, I am trying to export datatable to csv file but i m getting error at Response.End(); .
Can any one tell me what is the problem ?
private void Generate CSV(DataSet ds)
{
try
{
DataTable dt = null;
dt = ds.Tables[0];
if (dt == null)
{
string msg = "Invalid data";
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "FailureAlert('<strong>Sorry</strong>') " + msg + " '", true);
}
else
{
StringBuilder dataToExport = new StringBuilder();
if (dt.Rows.Count > 0)
{
// string maintype = string.Empty;
// string attachment = string.Empty;
// attachment = "attachment; filename=" + "UploadChq" + DateTime.Now.ToString("ddMMMyyyyhhmmss") + ".csv";
// System.Web.HttpContext.Current.Response.ClearContent();
// System.Web.Htt ...
Go to the complete details ...