Hello,
I have two function:-
protected void BtnDBExport_Click(object sender, EventArgs e)
{
ExportQrCodeDetails();
ExportAllCustomerDetails();
}
public void ExportQrCodeDetails()
{
SqlConnClass connClass = new SqlConnClass();
DataTable dt = connClass.Details();
GridView gv = new GridView();
gv.AutoGenerateColumns = false;
BoundField QRID = new BoundField();
QRID.HeaderText = "QRID";
QRID.DataField = "QRID";
gv.Columns.Add(QRID);
BoundField IMAGE = new BoundField();
IMAGE.HeaderText = "QRIMAGE";
IMAGE.DataField = "QRIMAGE";
gv.Columns.Add(IMAGE);
BoundField TILEIMAGE = new BoundField();
TILEIMAGE.HeaderText = "TILEIMAGE";
TILEIMAGE.DataField = "TILEIMAGE";
gv.Columns.Add(TILEIMAGE);
BoundField TILENAME = new BoundField();
TILENAME.HeaderText = "TILENAME";
TILENAME.DataField = "TILENAME";
gv.Columns.Add(TILENAME);
BoundField TILEDESC1 = new BoundField();
TILEDESC1.HeaderText = "TILEDESC1";
TILEDESC1.DataField = "TILEDESC1";
gv.Columns.Add(TILEDESC1);
gv.DataSource = dt;
gv.DataBind();
//StringWriter sw = new StringWriter();
//HtmlTextWriter htw = new HtmlTextWriter(sw);
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.AllowPaging = false;
//Change the Header Row back to white color
gv.HeaderRow.Style.Add("background-color", "#FFFFFF");
//Applying stlye to gridview header cells
for (int i = 0; i < gv.HeaderRow.Cells.Count; i++)
{
gv.HeaderRow.Cells[i].Style.Add("background-color", "#507CD1");
}
int j = 1;
//Set alternate row color
foreach (GridViewRow gvrow in gv.Rows)
{
gvrow.BackColor = System.Drawing.Color.White;
if (j <= gv.Rows.Count)
{
if (j % 2 != 0)
{
for (int k = 0; k < gvrow.Cells.Count; k++)
{
gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
}
}
}
j++;
}
gv.RenderControl(htw);
Response.Write(htw);
ExportQRCodeGenerateImageTableData(sw.ToString());
}
public void ExportQRCodeGenerateImageTableData(string data)
{
string attach = "attachment;filename=QRGenerateImage.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attach);
Response.ContentType = "application/ms-excel";
Response.Write(data);
Response.End();
}
public void ExportAllCustomerDetails()
{
SqlConnClass connClass = new SqlConnClass();
//Response.ClearContent();
//Response.Buffer = true;
//Response.AddHeader("content-disposition", "attachment; filename=QRCode.xlsx");
//Response.ContentType = "application/ms-excel";
DataTable dt = connClass.GetAllCustDetails();
GridView gvCustomer = new GridView();
gvCustomer.AutoGenerateColumns = false;
BoundField CUSTID = new BoundField();
CUSTID.HeaderText = "CUSTID";
CUSTID.DataField = "CUSTID";
gvCustomer.Columns.Add(CUSTID);
BoundField CUSTNAME=new BoundField();
CUSTNAME.HeaderText="CUSTNAME";
CUSTNAME.DataField="CUSTNAME";
gvCustomer.Columns.Add(CUSTNAME);
gvCustomer.DataSource = dt;
gvCustomer.DataBind();
//StringWriter sw = new StringWriter();
//HtmlTextWriter htw = new HtmlTextWriter(sw);
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvCustomer.AllowPaging = false;
//Change the Header Row back to white color
gvCustomer.HeaderRow.Style.Add("background-color", "#FFFFFF");
//Applying stlye to gridview header cells
for (int i = 0; i < gvCustomer.HeaderRow.Cells.Count; i++)
{
gvCustomer.HeaderRow.Cells[i].Style.Add("background-color", "#507CD1");
}
int j = 1;
//Set alternate row color
foreach (GridViewRow gvrow in gvCustomer.Rows)
{
gvrow.BackColor = System.Drawing.Color.White;
if (j <= gvCustomer.Rows.Count)
{
if (j % 2 != 0)
{
for (int k = 0; k < gvrow.Cells.Count; k++)
{
gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
}
}
}
j++;
}
gvCustomer.RenderControl(htw);
Response.Write(htw);
ExportAllCustomerTableData(sw.ToString());
}
public void ExportAllCustomerTableData(string data)
{
string attach = "attachment;filename=CustomerDetails.xls";
Response.ClearHeaders();
Response.AddHeader("content-disposition", attach);
Response.ContentType = "application/ms-excel";
Response.Write(data);
Response.End();
}
I want to call another function after one function.
but Only first function is running but another function did not run.
Second function is not calling after first's function Responce.End().
Basically second function is not calling after Response.End().
Please help me.
Thanks in Advance.
Ankit Agarwal
Software Engineer