public void GetDeviation() { try { int DeviationID = Convert.ToInt32(Request.QueryString["Id"]); DSdtls = obj_Deviation.GetInwardForPrint(DeviationID, out StrError); if (DSdtls.Tables.Count > 0) { if (DSdtls.Tables[0].Rows.Count > 0) { lblDeviationNo.Text = Obj_Comm.ToTitleCase(DSdtls.Tables[0].Rows[0]["DeviationNo"].ToString()); lblDeviationDate.Text = Obj_Comm.ToTitleCase(DSdtls.Tables[0].Rows[0]["DeviationDate"].ToString()); lblPreparedBy.Text = Obj_Comm.ToTitleCase(DSdtls.Tables[0].Rows[0]["UserName"].ToString()); lblDaviationFrom.Text = Obj_Comm.ToTitleCase(DSdtls.Tables[0].Rows[0]["DevationPeriod"].ToString()); } if (DSdtls.Tables[1].Rows.Count > 0) { GrdDeviation.DataSource = DSdtls.Tables[1]; GrdDeviation.DataBind(); ViewState["ImportExel"] = DSdtls.Tables[1]; } } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void ImgBtnExport_Click(object sender, ImageClickEventArgs e) { try { dttable = (DataTable)ViewState["ImportExel"]; if (dttable.Rows.Count > 0) { //========Call Register GridView GridExp = new GridView(); GridExp.DataSource = dttable; GridExp.DataBind(); Obj_Comm.Export("Deviation-Details" + "_" + DateTime.Now.ToString("dd-MMM-yyyy") + ".xls", GridExp); } else { Obj_Comm.ShowPopUpMsg("No Data Found To Export..!", this.Page); dttable = null; GrdDeviation.DataSource = null; GrdDeviation.DataBind(); } } catch (ThreadAbortException tex) { } catch (Exception ex) { } }