protected void Page_Load(object sender, EventArgs e) { if (Session["Login"] == null) { Response.Redirect("Login.aspx"); } ControlCliente = (C_Cliente)Session["ControlCliente"]; ControlConfig = (C_Configuracion)Session["ControlConfig"]; TodosClientes.DataSource = ControlCliente.Listar(); TodosClientes.DataBind(); Aux = ControlCliente.Listar(); if (Aux.Count == 0) { BtnConvtExcel.Enabled = false; BtnConvtPDF.Enabled = false; BtnConvtWord.Enabled = false; ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "erroralert();", true); } if (!IsPostBack) { TodosClientes.PageSize = ControlConfig.DevolverNroMaxPaginacion(); TodosClientes.DataSource = ControlCliente.Listar(); TodosClientes.DataBind(); } }
protected void TodosClientes_PageIndexChanging(object sender, GridViewPageEventArgs e) { TodosClientes.PageIndex = e.NewPageIndex; TodosClientes.DataSource = ControlCliente.Listar(); TodosClientes.DataBind(); TodosClientes.PageSize = ControlConfig.DevolverNroMaxPaginacion(); }
public void ConvertWord() { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=ListaClienteWord.doc"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-word "; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); TodosClientes.AllowPaging = false; TodosClientes.DataBind(); TodosClientes.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); }
public void ConvertPDF() { Response.AddHeader("content-disposition", "attachment;filename=ListaClientePDF.pdf"); Response.ContentType = "application/pdf "; Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); TodosClientes.AllowPaging = false; TodosClientes.DataBind(); TodosClientes.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document DocPDF = new Document(PageSize.A3, 10f, 10f, 10f, 0f); PdfWriter writer = PdfWriter.GetInstance(DocPDF, Response.OutputStream); DocPDF.Open(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, DocPDF, sr); DocPDF.Close(); Response.Write(DocPDF); Response.End(); }