如何在 DotNetNuke(DNN) 中以 Pdf 格式导出 Gridview 数据?
代码背后的代码是: -
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=PurchaseOrderDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView gridview1 = new GridView();
gridview1.AllowPaging = false;
//DataSet ds = objOrderRegistratonController.GetOrders();
grddisplay.DataBind();
grddisplay.RenderControl(hw);
grddisplay.HeaderRow.Style.Add("width", "15%");
grddisplay.HeaderRow.Style.Add("font-size", "10px");
grddisplay.Style.Add("text-decoration", "none");
grddisplay.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
grddisplay.Style.Add("font-size", "8px");
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
错误来了:- 'gridview' 类型的控件必须放在带有 runat=server 的表单标签内
我也尝试使用这种方法,因为许多人给出了解决方案,它的网格视图渲染问题 public override void VerifyRenderingInServerForm(Control control) { //base.VerifyRenderingInServerForm(control); }
但是这种方法在 DNN 'MPPR.mpprcms_OrderRegistraton.ViewPurchaseOrder.VerifyRenderingInServerForm(System.Web.UI.Control)' 中给出错误:找不到合适的方法来覆盖
请给出合适的解决方案