예제 #1
0
        public void GridProcessBind()
        {
            DataTable dtWip = DBLibrary.GetWIPDetails(Convert.ToInt32(ddlStage.SelectedValue), Convert.ToInt32(ddlProcess.SelectedValue));

            GVChangeProcess.DataSource = dtWip;
            GVChangeProcess.DataBind();

            if (dtWip.Rows.Count > 0)
            {
                //btnUpdate.Visible = true;
                Export_Link.Visible = true;
            }
            else
            {
                //btnUpdate.Visible = false;
                Export_Link.Visible = false;
            }
        }
예제 #2
0
        protected void Export_Link_Click(object sender, EventArgs e)
        {
            try
            {
                Response.ClearContent();
                Response.Buffer = true;
                Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
                Response.ContentType = "application/ms-excel";
                StringWriter   sw  = new StringWriter();
                HtmlTextWriter htw = new HtmlTextWriter(sw);
                GVChangeProcess.AllowPaging = false;
                GridProcessBind();
                //Change the Header Row back to white color
                GVChangeProcess.HeaderRow.Style.Add("background-color", "#FFFFFF");
                //Applying stlye to gridview header cells
                for (int i = 0; i < GVChangeProcess.HeaderRow.Cells.Count; i++)
                {
                    GVChangeProcess.HeaderRow.Cells[i].Style.Add("background-color", "#294a77");
                }
                // Hides the first column in the grid (zero-based index)
                GVChangeProcess.HeaderRow.Cells[9].Visible  = false;
                GVChangeProcess.HeaderRow.Cells[10].Visible = false;

                // Loop through the rows and hide the cell in the first column
                for (int i = 0; i < GVChangeProcess.Rows.Count; i++)
                {
                    GridViewRow row = GVChangeProcess.Rows[i];
                    row.Cells[9].Visible  = false;
                    row.Cells[10].Visible = false;
                }

                GVChangeProcess.RenderControl(htw);
                Response.Write(sw.ToString());
                Response.End();
            }
            catch (Exception err)
            {
                ShowMessage(err.Message);
            }
        }