GeidView打印报表,有列不打印问题,在线等
gridview 的列有:姓名列,性别列,详细列,删除列
在查看gridview数据是 需要显示 【详细列,删除列】 但是,打印出来的报表中确不需要【详细列,删除列】
我的打印代码如下,求指教:
Response.Clear();
Response.Buffer = false;
Response.Charset = "utf-8";
Response.AppendHeader("Content-Disposition", "attachment;filename=recordWork.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
Response.ContentType = "application/ms-excel";
Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
GridView1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
[解决办法]
在GridView1.RenderControl之前,绑定事件里面进行隐藏。