DataGrid: apply style every 60 lines

Posted on 2006-04-13
Last Modified: 2008-02-07
I am trying to insert pagebreaks into a DataGrid which needs to be printed.
I have found a partial solution at:

This says to use a style on the <TR>, like this:
<tr style="page-break-before: always;">

This works great in plain html, but how do I tell my DataGrid to build this into every 60th <TR> ?
Question by:astromex
    LVL 2

    Expert Comment

    I'm not sure you can actually break the datagrid.

    Best thing, if you have crystal reports, you can have your report formatted the right way and output it to the web as a pdf, etc., including breaks.

    sorry I can't give you a better solution, but I've needed to do that also because there's no way to break a least I couldn't find one.

    Good Luck.
    LVL 15

    Accepted Solution

    In the OnItemDataBound event you should be able to add this style to the row every 60 rows.

    Create a public variable and when that hits a multiple of 60 add the style.


    Author Comment

    Thanks GavinMannion, That worked very well indeed !

      Public RowCount as Integer
      Protected Sub ApplyStyle(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
        RowCount = RowCount+1
        If RowCount=60 then
        End If
      End Sub
    LVL 15

    Expert Comment

    :), Hey it's only a pleasure.

    I just got my first points in the VB.NET TA and I can't even code in VB properly :)....

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now