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. Image for the cookie policy date

I cant print grid.

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;

1 Reply

JG Jai Ganesh S Syncfusion Team 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 

Live Chat Icon For mobile
Up arrow icon