Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1690
  • Last Modified:

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

0
M3mph15
Asked:
M3mph15
  • 2
1 Solution
 
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
 
M3mph15Author Commented:
Hi, Your solution worked perfectly thankyou!!!
0
 
Juan_BarreraCommented:
No worries! Good luck!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now