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

I cant print grid.

Thread ID:





125661 Aug 31,2016 03:55 PM UTC Sep 1,2016 12:52 PM UTC UWP 1
Tags: SfDataGrid
Andrew Overlord
Asked On August 31, 2016 03:55 PM UTC

When i try to print my grid i have this error: "Value cannot be null."

This is my code:
            SfDataGrid dataGrid = new SfDataGrid();
            dataGrid.Columns.Add(new GridTextColumn() { HeaderText = "Order ID", MappingName = "OrderID" });
            dataGrid.Columns.Add(new GridTextColumn() { HeaderText = "Customer ID", MappingName = "CustomerID" });
            dataGrid.Columns.Add(new GridTextColumn() { HeaderText = "Customer Name", MappingName = "CustomerName" });
            dataGrid.Columns.Add(new GridTextColumn() { HeaderText = "Country", MappingName = "Country" });
            dataGrid.Columns.Add(new GridNumericColumn() { HeaderText = "Unit Price", MappingName = "UnitPrice" });
            dataGrid.PrintSettings = new PrintSettings();
            dataGrid.PrintSettings.PrintPageOrientation = PrintOrientation.Portrait;

Jai Ganesh S [Syncfusion]
Replied On September 1, 2016 12:52 PM UTC

Hi Andrew,

Thanks for contacting Syncfusion Support.

In SfDataGrid  it is not possible to perform the Print operation without creating the SfDataGrid.View. But you can achieve your requirement “printing a SfDataGrid from code behind” by using the below code example, Here we have created the SfDataGrid.View manually.


SfDataGrid grid = new SfDataGrid(); 
            grid.ItemsSource = (new OrderInfoViewModel()).OrdersListDetails; 
            GridQueryableCollectionViewWrapper wrapper = new GridQueryableCollectionViewWrapper((this.DataContext as OrderInfoViewModel).OrdersListDetails, grid); 
            grid.ItemsSource = wrapper; 
            grid.Columns.Add(new GridTextColumn() { MappingName = "CustomerID" }); 
            grid.Columns.Add(new GridTextColumn() { MappingName = "Discount" }); 
            grid.PrintSettings = new PrintSettings(); 
            grid.PrintSettings.PrintManagerBase = new PrintManagerBase(wrapper); 
            grid.PrintSettings.PrintPageOrientation = PrintOrientation.Portrait; 


We have prepared a sample as per your requirement and you can download the sample from the below location,

Sample :  

Jai Ganesh S 


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