Using Page Breaks in a Repeater

Hi all,

I have a table inside a asp:Repeater which i display data from a database. (See attached Code). I have used a repeater because the query returns many results and I am wanting to create a Page Break after each table. At the moment i am using <hr size="1" style="PAGE-BREAK-AFTER: right; color: #FFFFFF;">.

Which does create the page breaks but the only problem is that it gets to the last record and still inserts a page break which prints a blank page.

Is there a bettwer way to set this up so it doesn't print the blank page.

Thanks in advanced
-M3mph15
<div style="text-align: center; font-family: Arial; font-size: medium;">
        <asp:Repeater ID="repParty" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
        <asp:Table ID="Table1" runat="server" Width="80%" BackColor="Black" CellPadding="1" CellSpacing="1" GridLines="Both">
            <asp:TableRow ID="TableRow1" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Party Id</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "PARTY_ID")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow2" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Party Name</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "PARTY_NAME")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow3" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Category</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "CATEGORY")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow4" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Sub Category</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "SUB_CATEGORY")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow5" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Title</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "FUNCTION_TITLE")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow6" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Organisation Name</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "ORGANISATION_NAME")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow7" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Phone No 1</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "PHONE1_NUMBER")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow8" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Phone No 2</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "PHONE2_NUMBER")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow9" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Mobile no</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "MOBILE_NUMBER")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow10" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Fax No</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "FAX_NUMBER")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow11" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Email</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "EMAIL")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow26" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Best Way to Contact</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "BEST_WAY_TO_CONTACT")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow12" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Postal Address</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;</asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow13" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;Street</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "NUMBER_STREET_NAME")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow14" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;Suburb</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "SUBURB")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow15" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;Post Code</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "POST_CODE")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow16" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;State</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "PSTATE")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow17" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Residential Address</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;</asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow18" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;Street</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "RESIDENTIAL_NUMBER_STREET_NAME")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow19" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;Suburb</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "RESIDENTIAL_SUBURB")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow20" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;Post Code</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "RESIDENTIAL_POST_CODE")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow21" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">&nbsp;&nbsp;State</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "RSTATE")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow22" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Main Business Description</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "MAIN_BUSINESS_DESCRIPTION")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow23" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Party Description</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "PARTY_DESCRIPTION")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow24" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Comment</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "PARTY_COMMENT")%></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="TableRow25" runat="server" BackColor="White">
                <asp:TableCell HorizontalAlign="Left">Status</asp:TableCell>
                <asp:TableCell HorizontalAlign="Left">&nbsp;<%#DataBinder.Eval(Container.DataItem, "STATUS")%></asp:TableCell>
            </asp:TableRow>
            </asp:Table>
            <hr size="1" style="PAGE-BREAK-AFTER: right; color: #FFFFFF;">
        </ItemTemplate>
        </asp:Repeater>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:IAG Connection %>" 
            ProviderName="<%$ ConnectionStrings:IAG Connection.ProviderName %>" 
            SelectCommand="SELECT par.PARTY_ID, (SELECT cat.CATEGORY_NAME FROM IAG_PARTY_CATEGORIES cat WHERE cat.ID=par.PARTY_CATEGORY) as CATEGORY, 
(SELECT sub.SUB_CATEGORY_NAME FROM IAG_PARTY_SUB_CATEGORY sub WHERE sub.ID=par.PARTY_SUB_CATEGORY) as SUB_CATEGORY, par.PARTY_NAME, par.FUNCTION_TITLE, par.PARTY_DESCRIPTION, par.BEST_WAY_TO_CONTACT, par.ORGANISATION_NAME, par.PHONE1_NUMBER, par.PHONE2_NUMBER, par.MOBILE_NUMBER, par.FAX_NUMBER, par.EMAIL, par.NUMBER_STREET_NAME, par.SUBURB, par.POST_CODE, (SELECT crc.RV_MEANING FROM COM.CG_REF_CODES crc WHERE crc.RV_ACTIVE='Y' AND crc.RV_DOMAIN='IAG_STATE' AND crc.RV_LOW_VALUE=par.STATE) as PSTATE, par.RESIDENTIAL_DIFFERENT_POSTAL, par.RESIDENTIAL_NUMBER_STREET_NAME, par.RESIDENTIAL_SUBURB, par.RESIDENTIAL_POST_CODE, (SELECT crc.RV_MEANING FROM COM.CG_REF_CODES crc WHERE crc.RV_ACTIVE='Y' AND crc.RV_DOMAIN='IAG_STATE' AND crc.RV_LOW_VALUE=par.RESIDENTIAL_STATE) as RSTATE, par.MAIN_BUSINESS_DESCRIPTION, (SELECT crc.RV_MEANING FROM COM.CG_REF_CODES crc WHERE crc.RV_ACTIVE='Y' AND crc.RV_DOMAIN='IAG_PARTY_STATUS' AND crc.RV_LOW_VALUE=par.STATUS) STATUS, par.PARTY_COMMENT FROM IAG_PARTIES">
        </asp:SqlDataSource>
    </div>

Open in new window

LVL 6
M3mph15Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Juan_BarreraCommented:
Hi, please try the following code and let me know:

 Protected Sub repParty_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repParty.ItemDataBound
        If e.Item.ItemType = ListItemType.Item Then
            Dim row As Data.DataRowView = CType(e.Item.DataItem, Data.DataRowView)
            If Not e.Item.ItemIndex = row.DataView.Count Then
                Dim l As New Literal
                l.Text = "<hr size='1' style='PAGE-BREAK-AFTER: right; color: #FFFFFF;'>"
                e.Item.Controls.Add(l)
            End If
        End If
    End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
M3mph15Author Commented:
Hi, Your solution worked perfectly thankyou!!!
0
Juan_BarreraCommented:
No worries! Good luck!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.