Printing A Datagrid in WEBFORM

  • Thread starter Thread starter I'm Home
  • Start date Start date
I

I'm Home

I've read a lot of suggestions including the "javascript:printWindow()"
command ... what I want ... the entire datagrid in printed form using my css
style.
What I get the page displayed on my screen ... about what I'd see with a
screen capture and print.

Does anyone have any idea how to do an event that selects the datagrid and
prints the datagrid instead of just a chopped off image?
 
I read through the article, hooked up my html to link to the print.css, but
when I use File/Print from my browser I still get the same old thing. A
chopped off image of my datagrid.

I've seen some apparently good articles that explain how to use an
htmlwriter to capture the datagrid but I can't get beyond this statement /
problem:
_______________________________________________
===>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 85: Dim htmlTW As New HtmlTextWriter(SW)
Line 86: ' ERROR ... DataGrid1.RenderControl(htmlTW)
Line 87: DataGrid1.RenderControl(htmlTW)
<===============
Line 88: Dim dataGridHTML As String = SB.ToString()
Line 89:

THE LINES PRECEDING line 85 are:
' Get the rendered HTML

Dim SB As New System.Text.StringBuilder

Dim SW As System.IO.StringWriter

'Dim htmlTW As HtmlTextWriter

BTW, I'm invoking this logic using a webform button labeled "Print the
datagrid" ... maybe I should be doing the htmltextwriter "stuff" during
pageload when binding the datagrid ????

THANKS for any ideas, Bob

_________________________________________________________________
 
Back
Top