Using export to HTML feature you can print the grid very easily just by adding following JavaScript to the export output:

<script type=""text/javascript"">print();</script>

You can use WebClient to save the output as file on the server:

Silverlight client side:

Uri uri = new Uri(HtmlPage.Document.DocumentUri, String.Format("PrintHandler.aspx?FileName={0}", fileName));
WebClient client = new WebClient();
client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);
client.UploadStringAsync(uri, String.Format("{0}{1}", RadGridView1.ToHtml(), printScript));
ASP.NET server side:
protected void Page_Load(object sender, EventArgs e)
    if (Request.QueryString["FileName"] != null)
            new StreamReader(Request.InputStream).ReadToEnd(), Encoding.UTF8);

and request this file when upload is finished:

void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
    HtmlPage.Window.Navigate(new Uri(HtmlPage.Document.DocumentUri, fileName), "_blank", "menubar=0;toolbar=0;fullscreen=1;");

… and that’s it! :)

The result:
- RadGridView bound to RIA service completely codeless using DomainDataSource:

- Print preview with immediate print dialog:


If you have “Microsoft XPS Document Writer” you can save the grid output as XPS and using “Microsoft Office Document Image Writer” you can save the output as pageable TIFF!

There are many free PDF printers also and if you have some of them (I’m using this one) you can get the grid output immediately in PDF!


[Source Code] | [PDF Output]

About the Author

Vladimir Enchev

is Director of Engineering, Native Mobile UI & Frameworks


Comments are disabled in preview mode.