protected void LoadGrid() { // int iRowcount = 0; ht.Add("@Client_Id", client_Id); ht.Add("@Sub_ProcessId", Subprocess_id); dt = dataaccess.ExecuteSP("Sp_Rpt_ClientName_Invoice", ht); if (dt.Rows.Count > 0) { Grd_ClientName_Production.Visible = true; Grd_ClientName_Production.DataSource = dt; Grd_ClientName_Production.DataBind(); // iRowcount = iRowcount + 1; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["client_Id"] != "" && Session["subProcess_id"] != "") { client_Id = int.Parse(Session["client_Id"].ToString()); Subprocess_id = int.Parse(Session["subProcess_id"].ToString()); } LoadGrid(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Export_ClientName_Production.xls")); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); Grd_ClientName_Production.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); }