Jump to content

saya nurul

Learning
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Normal

About saya nurul

  • Rank
    Ahli Baru
  1. salam,   mcm ne kalu nk export gridview ke pdf file?sy telh cuba koding spt dibwh ni tp sy dpt error bila run. mcm ne nk solve mslh ni?   harap ada yg boleh membntu..Trima kasih :)      protected void btnExportPDF_Click(object sender, EventArgs e)         {             Response.ContentType = "application/pdf";             Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");             Response.Cache.SetCacheability(HttpCacheability.NoCache);             StringWriter sw = new StringWriter();             HtmlTextWriter hw = new HtmlTextWriter(sw);             //DataList1.AllowPaging = false;             DataList1.DataBind();             DataList1.RenderControl(hw);             //DataList1.HeaderRow.Style.Add("width", "15%");             //DataList1.HeaderRow.Style.Add("font-size", "10px");             DataList1.Style.Add("text-decoration", "none");             DataList1.Style.Add("font-family", "Arial, Helvetica, sans-serif;");             DataList1.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();         }     error yg keluar : The document has no pages. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.IOException: The document has no pages. Source Error: Line 208: pdfDoc.Open(); Line 209: htmlparser.Parse(sr); Line 210: pdfDoc.Close(); Line 211: Response.Write(pdfDoc); Line 212: Response.End();  
×
×
  • Create New...