Ejemplo n.º 1
0
        protected void btnD_Click(object sender, EventArgs e)
        {
            string fileName = "Managers.xls";

            AssociateServices employeeServices = new AssociateServices();

            DataGrid dg = new DataGrid
            {
                AllowPaging = false,
                DataSource  = employeeServices.GetAllAssociates()
            };

            dg.DataBind();

            System.Web.HttpContext.Current.Response.Clear();
            System.Web.HttpContext.Current.Response.Buffer          = true;
            System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
            System.Web.HttpContext.Current.Response.Charset         = "";
            System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition",
                                                              "attachment; filename=" + fileName);

            System.Web.HttpContext.Current.Response.ContentType =
                "application/vnd.ms-excel";
            System.IO.StringWriter       stringWriter   = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlTextWriter =
                new System.Web.UI.HtmlTextWriter(stringWriter);
            dg.RenderControl(htmlTextWriter);
            System.Web.HttpContext.Current.Response.Write(stringWriter.ToString());
            System.Web.HttpContext.Current.Response.End();
        }
Ejemplo n.º 2
0
        void BindData()
        {
            AssociateServices ascServices = new AssociateServices();

            lstEmployee.DataSource = ascServices.GetAllAssociates();
            lstEmployee.DataBind();
            HiddenField hf = (HiddenField)Parent.FindControl("hidLastTab");

            hf.Value            = "2";
            associatesAssigned  = ascServices.GetAssociatesCount();
            associatesAvailable = totalAssociates - associatesAssigned;
        }