INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ASP.Net Troubleshooting

Datagrid Gridlines do not Print after the First Page. by Mike555
Posted: 22 Feb 05 (Edited 15 Jul 05)

When printing a webform containing a datagrid longer than one printed page, the datagrid's gridlines may only print on Page 1.  This problem occurs due to an IE bug which effects borderCollapsing on client-side tables.  (The datagrid is rendered as a table during run-time)

There are 2 ways (which i know of) to work around this issue.

1st Method- Simply implement Paging within your datagrid to ensure that records never print past page 1.

2nd Method- Implement the following 2 Javascript functions into the HTML view of the webform containing the datagrid...

CODE

<HTML>
<HEAD>
<SCRIPT language="Javascript">
        function clearAttrs()
        {
        document.all.DataGrid1.style.borderCollapse = "separate";
        }
        function setAttrs()
        {
        document.all.DataGrid1.style.borderCollapse = "collapse";
        }
</SCRIPT>
</HEAD>
<body onafterprint="setAttrs() onbeforeprint="clearAttrs()>
</body>
</HTML>
However, if you have a datagrid that is not visible when the page initially loads, you may need to format your Javascript a bit differently.  For example, you have 2 datagrids, DataGrid1 & DataGrid2, located on a webform which are not initially visible when the page loads.  You may need to format the Javascript as follows...

CODE

<HTML>
<HEAD>
<SCRIPT language="Javascript">
        function clearAttrs()
        {
        if (document.all.DataGrid1 != null)
            document.all.DataGrid1.style.borderCollapse = "separate";
        else if (document.all.DataGrid2 != null)
            document.all.DataGrid2.style.borderCollapse = "separate";
        }
        function setAttrs()
        {
        if (document.all.DataGrid1 != null)
            document.all.DataGrid1.style.borderCollapse = "collapse";
        else if (document.all.DataGrid2 != null)
            document.all.DataGrid2.style.borderCollapse = "collapse";
        }
</SCRIPT>
</HEAD>
<body onafterprint="setAttrs() onbeforeprint="clearAttrs()>
</body>
</HTML>

HTH,
Mike

Back to Microsoft: ASP.NET FAQ Index
Back to Microsoft: ASP.NET Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close