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.
Unfortunately, activation email could not send to your email. Please try again.

Need help in binding Datasource to PDFGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,

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:
StackTrace
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();
try
{
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);

}

else
{

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

}


}
//////////////////

Thanks for your time.

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

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.

Documentation:

http://help.syncfusion.com/ug_82/Reporting_PDF/GridCreation.html

Let us know if you have any questions.

Regards,
Pravin.


CONFIRMATION

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.

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.

;