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.

How to print SfDataGrid with Header and footer?

You can print the SfDataGrid with Header and Footer content by using PrintPageHeaderTemplate and PrintPageFooterTemplate properties in SfDataGrid.PrintSettings. By default, SfDataGrid prints without Header and Footer content.

The following code example explains the Footer data template definition for SfDataGrid. While printing, the data template is set to ContentControl in PrintPreviewAreaControl. From PrintPreviewAreaControl, you can access the following properties by using Ancestor binding in the data template.

  1. PageIndex – denotes the current page index that is printing
  2. TotalPages – Total number of pages to be printed

XAML

In the above code example, TodayDate is a normal CLR property in the type of DateTime that is used to store today’s date by using DateTime.Today.

The following code example explains how to set Footer Data Template to PrintSettings.PrintPageFooterTemplate in SfDataGrid.

C#

 

C:\Users\Giftline\Desktop\img.jpg Note: Using the same method, you can also set PrintPageHeaderTemplate while printing.

The following screenshot displays the print preview of SfDataGrid with Header and Footer.

F:\Issuesample\KB's\Print\withtitle.png

You can refer to the sample from the following location.

Sample Link: PrintGridWithHeaderAndFooter_SilverLight.zip

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
3117 01/08/2015 06/08/2015 Silverlight SfDataGrid 4.5.1
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.