protected void BindGridView() { try { if (ds.Tables["InboundSortTable"] == null) { } else if (ds.Tables["InboundSortTable"].Rows.Count == 0) { MakeEmptyGridView(GridViewInSort, "InboundSortTable"); } else { GridViewInSort.PageSize = maxRows; GridViewInSort.DataSource = ds.Tables["InboundSortTable"].DefaultView; GridViewInSort.DataBind(); } if (ds.Tables["OutboundSortTable"] == null) { } else if (ds.Tables["OutboundSortTable"] == null || ds.Tables["OutboundSortTable"].Rows.Count == 0) { MakeEmptyGridView(GridViewOutSort, "OutboundSortTable"); } else { GridViewOutSort.PageSize = maxRows; GridViewOutSort.DataSource = ds.Tables["OutboundSortTable"].DefaultView; GridViewOutSort.DataBind(); } if (lstShipmentType.SelectedIndex == 1) { GridViewOutSort.Visible = false; GridViewInSort.Visible = true; bindChildGridView("InboundSortTable", "InboundTable", "GridViewInDetail", GridViewInSort, "InboundRelation"); } else if (lstShipmentType.SelectedIndex == 2) { GridViewOutSort.Visible = true; GridViewInSort.Visible = false; bindChildGridView("OutboundSortTable", "OutboundTable", "GridViewOutDetail", GridViewOutSort, "OutboundRelation"); } else { GridViewOutSort.Visible = true; GridViewInSort.Visible = true; bindChildGridView("InboundSortTable", "InboundTable", "GridViewInDetail", GridViewInSort, "InboundRelation"); bindChildGridView("OutboundSortTable", "OutboundTable", "GridViewOutDetail", GridViewOutSort, "OutboundRelation"); } } catch { } }
protected void ExcelPrintButton_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=customer_recap_" + System.DateTime.Today.ToString("yyyy-MM-dd") + ".xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving then // comment out the line below // Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GridViewOutSort.RenderControl(htmlWrite); GridViewInSort.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); }