Estoy utilizando Visual Studio 2008 y SQL Server 2008cuadrícula de impresión con mesa en asp.net
Quiero imprimir mi "gridview con mesa" usando un botón en asp.net 3.5 código tiene tres partes por primera vez este es de mi página por defecto
protected void btnPrint_Click(object sender, EventArgs e)
{
Session["ctrl"] = Panel1;
ClientScript.RegisterStartupScript(this.GetType(), "onclick",
"<script language=javascript>window.open('Print.aspx','PrintMe','height=300px,width=300px,scrollbars=1');</script>");
PrintHelper.PrintWebControl(Panel1);
}
el código de la página de impresión de este
protected void Page_Load(object sender, EventArgs e)
{
Control ctrl = (Control)Session["ctrl"];
PrintHelper.PrintWebControl(ctrl);
}
y esta es mi impresión clase de ayuda
public PrintHelper()
{
}
public static void PrintWebControl(Control ctrl)
{
PrintWebControl(ctrl, string.Empty);
}
public static void PrintWebControl(Control ctrl, string Script)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
}
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}
favor me ayude a cabo
esta pregunta es demasiado vaga. más detalles necesarios: dónde, qué ... – onof
he creado una página web que imprime mi vista de cuadrícula que muestra los datos en gridview pero el problema es que no me muestra las filas y columnas de la vista de cuadrícula – CHANDRAHAS
¿Puede mostrarnos el código que tienes hasta ahora, así que no estamos adivinando? – RQDQ