DataGrid: apply style every 60 lines

Hi,
I am trying to insert pagebreaks into a DataGrid which needs to be printed.
I have found a partial solution at:
http://techrepublic.com.com/5208-11196-0.html?forumID=73&threadID=187861

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> ?
Thanks
astromexAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GavinMannionConnect With a Mentor Commented:
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.

0
 
af4643Commented:
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 datagrid...at least I couldn't find one.

Good Luck.
0
 
astromexAuthor Commented:
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
      e.Item.Style.Add("page-break-before","always")
      RowCount=0
    End If
  End Sub
0
 
GavinMannionCommented:
:), 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 :)....
0
All Courses

From novice to tech pro — start learning today.