Sorry if its too absurd question. but I have an asp button that calls an events. Event creates a datatable and downloading the datatable as xls. It works fine, I can see the downloaded file but I can not see the gridview that I show the datatable. Does anybody have an idea about it.
Response.ClearContent();
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
Response.Charset = "windows-1254";
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/xsl";
string tab = "";
foreach (DataColumn c in dt.Columns)
{
Response.Write(tab + c.ColumnName);
tab = "\t";
}
\\..somethings about writing to file ...
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.SuppressContent = true;
HttpContext.Current.ApplicationInstance.CompleteRequest();
I tried create datatable and import to gridview after response.flush(). When I debugging the code below it works fine. I can see the variables in debug section but gridview still not seeable.
Response.ClearContent();
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
Response.Charset = "windows-1254";
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/xsl";
string tab = "";
foreach (DataColumn c in dt.Columns)
{
Response.Write(tab + c.ColumnName);
tab = "\t";
}
\\..somethings about writing to file ...
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.SuppressContent = true;
HttpContext.Current.ApplicationInstance.CompleteRequest();
queryString = textbox.Text.Replace("\r\n", " ").ToString();
table = connectDatabase(queryString);
GridView1.DataSource = table;
GridView1.DataBind();
if (GridView1.Rows.Count > 0)
{
GridView1.Visible = true;
}