We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Need help in binding Datasource to PDFGrid

Thread ID:





95435 Jul 8,2010 09:31 AM UTC Jul 8,2010 10:17 AM UTC ASP.NET Web Forms (Classic) 1
Tags: PDF
Adrian Hedley
Asked On July 8, 2010 09:31 AM UTC


Bear with me as I am new to this..
I need to print Gridview (ASP.net) contents into a PDF page.
When binding my DataSource to the PdfGrid, it throws the following Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Pdf.Grid.PdfGrid.PopulateHeader()
at Syncfusion.Pdf.Grid.PdfGrid.SetDataSource()
at Syncfusion.Pdf.Grid.PdfGrid.set_DataSource(Object value)

Any help much appreciated..
Code snippet::
public void PrintToPdf()
PdfDocument doc = new PdfDocument();

//Add a page

PdfPage page = doc.Pages.Add();

//Create Pdf graphics for the page

PdfGraphics g = page.Graphics;

//Create a solid brush

PdfBrush brush = new PdfSolidBrush(Color.Black);

float fontSize = 20f;

//Set the font

PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, fontSize);

DAL.emsDAL dal = new DAL.emsDAL();
PdfGrid grid = new PdfGrid();

List result = dal.getResults(1, 1, 1, new DateTime(2010, 7, 1), new DateTime(2010, 7, 5));//dal.getResults(plantID, chimID, pollID, dateFrom, dateTo);

// DataSource shows a count of 120.

grid.DataSource = result;// Exception is thrown here!!

grid.Draw(page.Graphics, PointF.Empty, 100);

catch (Exception ex)
{ }

//Stream the output to the browser.

if (this.CheckBox1.Checked)

doc.Save("Sample.pdf", Response, HttpReadType.Open);



doc.Save("Sample.pdf", Response, HttpReadType.Save);



Thanks for your time.

Pravin Joshua D [Syncfusion]
Replied On July 8, 2010 10:17 AM UTC

Hi Adrain,

Thank you for using Essential PDF.

It is not possible to pass a list as datasource for the PdfGrid.The datasource for a PdfGrid can be an array (two-dimensional, one-dimensional or nested), a DataTable, DataColumn, DataView or DataSet.

Please refer to the documentation in the link below, for more details.



Let us know if you have any questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon