Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
How to export an Item template from a WebGrid to a Pdf document
posted

Hi, I want to export data from a webgrid to a Pdf document, but when I export the itemtemplate columns don't appear in the pdf document.

I order to export all colums from my grid, I was trying to make a copy of my current webgrid by setting the datasource in another one without itemtemplate columns, but when I send to export data I receive a error message.

 

//My code to create and set the datasource in the webgrid is:

UltraWebGrid webGridDocument = new UltraWebGrid("webGridDocument");

webGridDocument.Columns.Add("Date", "Date");

webGridDocument.Columns.Add("Name", "Name");

webGridDocument.Columns.Add("ProductName", "Product");

webGridDocument.Columns.Add("StockValue", "Quantity");

webGridDocument.Columns.Add("Comments", "Comments");webGridDocument.DataSource = myDatasource;

webGridDocument.DataBind();

 

// trigger export. Here export the grid.

WebGridDocumentExporter.Export(webGridDocument);

 

I am sure that the datasource has data (It is a datatable)

but I receive the following message.

Server Error in '/' Application.

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 399:
Line 400:            // trigger export
Line 401:            WebGridDocumentExporter.Export(webGridDocument);
Line 402:
Line 403:        }

 

Could you help me In order that I could export Itemtemplate column to a PDF? if it is not possible, please help me to solve the export error message. 

 

Parents
No Data
Reply
  • 135
    posted

    Hi, I have fixed the problem for creating the webgrid. It was missing to add to the form.

    Now, the only question is if anybody know how to export an itemtemplate column to a document.

    thanks,

    PJ

Children
No Data