Hi members
i have a printing page it has a header and a gridview(table) and a footer
my problem is to make the footer(Labels) in last page and not repeated because my try i get it repeated
this is my try
<style id="gridStyles" runat="server" type="text/css">
body { font-family: Arial; font-size: 10pt; width: 80%; }
table { border: 1px solid #ccc; border-collapse: collapse; font-size: 12pt; }
table th { color: #0090CB; font-weight: lighter; font-size: medium; }
table th, table td { padding: 1px; border: 1px solid #ccc; }
table, table table td { border: 0px solid #ccc; }
thead { display: table-header-group; }
tfoot { display: table-footer-group; }
.auto-style1 { width: 120%; }
.auto-style2 { width: 734px; }
.pan1 { position: relative; bottom: 5px; Left: 0px; width: 100%; height: 20%; z-index: 500; }
/*.pan2{
position: fixed;
top: 5px;
Left: 0px;
width: 100%;
height: 20%;
z-index:5;
margin-bottom:50px;
}*/
.auto-style3 { position: fixed; bottom: -203px; Left: 7px; width: 100%; height: 20%; z-index: 500; }
</style>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel2" runat="server" Style="align-content: center;" Height="39px" CssClass="pan2">
<table class="auto-style1">
<tr style="text-align: center;">
<td>
<asp:Label ID="Label1" runat="server" Text="Inventaires Magasin Stupremat" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
</tr>
</table>
<br />
</asp:Panel>
<asp:GridView ID="GridView1" runat="server" AllowPaging="true" PageSize="60" OnPageIndexChanging="OnPageIndexChanging" Height="16px" Width="887px" CellPadding="5">
</asp:GridView>
<asp:Panel ID="Panel1" runat="server" Height="200px" CssClass="pan1">
<hr />
<hr />
<table class="auto-style1" style="bottom: 0%; position: fixed;">
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Small" Text="Effectué par"></asp:Label>
</td>
<td>
<asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Small" Text="Controlé par"></asp:Label>
</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</asp:Panel>
<hr />
<asp:Button ID="btnPrintCurrent" runat="server" Text="Imprimer la page courant" OnClick="PrintGridView"
CommandArgument="Current" BackColor="#660033" BorderColor="#66CCFF" BorderStyle="Double" BorderWidth="2px" Font-Bold="False" Font-Italic="True" ForeColor="#CCFFFF" Width="164px" />
<asp:Button ID="btnPrintAll" runat="server" Text="Imprimer tout les pages" OnClick="PrintGridView"
CommandArgument="All" BackColor="#660033" BorderColor="#66CCFF" BorderStyle="Double" BorderWidth="2px" Font-Bold="False" Font-Italic="True" ForeColor="#CCFFFF" Width="164px" />
<script type="text/javascript">
function PrintGrid(html, css) {
var printWin = window.open('', '', 'left=0,top=0,width=1000,height=800,scrollbars=1');
printWin.document.write('<style type = "text/css">' + css + '</style>');
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
};
</script>
<asp:Button ID="Button1" runat="server" Text="Fermer" BackColor="#660033" BorderColor="#66CCFF" BorderStyle="Double" BorderWidth="2px" Font-Bold="False" Font-Italic="True" ForeColor="#CCFFFF" Width="164px" />
</div>
Imports System.Data
Imports System.IO
Code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.BindGrid()
Panel1.Visible = False
Panel2.Visible = False
End If
End Sub
Protected Sub OnPageIndexChanging(sender As Object, e As GridViewPageEventArgs)
GridView1.PageIndex = e.NewPageIndex
Me.BindGrid()
End Sub
Protected Sub PrintGridView(ByVal sender As Object, ByVal e As EventArgs)
Panel1.Visible = True
Panel2.Visible = True
'Disable Paging if all Pages need to be Printed.
If (CType(sender, Button).CommandArgument = "All") Then
'Disable Paging.
GridView1.AllowPaging = False
'Re-bind the GridView.
Me.BindGrid()
'For Printing Header on each Page.
GridView1.UseAccessibleHeader = True
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader
GridView1.FooterRow.TableSection = TableRowSection.TableFooter
GridView1.Attributes("style") = "border-collapse:separate"
For Each row As GridViewRow In GridView1.Rows
If (row.RowIndex + 1) Mod GridView1.PageSize = 0 AndAlso row.RowIndex <> 0 Then
row.Attributes("style") = "page-break-after:always;"
End If
Next
Else
'Hide the Pager.
GridView1.PagerSettings.Visible = False
Me.BindGrid()
End If
Using sw As StringWriter = New StringWriter
'Render GridView to HTML.
Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
Panel2.RenderControl(hw)
GridView1.RenderControl(hw)
Panel1.RenderControl(hw)
'Enable Paging.
GridView1.AllowPaging = True
Me.BindGrid()
'Remove single quotes to avoid JavaScript error.
Dim gridHTML As String = sw.ToString.Replace(Environment.NewLine, "")
Dim gridCSS As String = gridStyles.InnerText.Replace("""", "'").Replace(Environment.NewLine, "")
'Dim gridHTML As String = lblHeader.Text + "<hr />"
'gridHTML += sw.ToString().Replace(Environment.NewLine, "")
'gridHTML += "<br />" + lblFooter.Text
' Print the GridView.
Dim script As String = "window.onload = function() { PrintGrid('" & gridHTML & "', '" & gridCSS & "'); }"
ClientScript.RegisterStartupScript(Me.GetType(), "GridPrint", script, True)
End Using
Panel1.Visible = False
Panel2.Visible = False
End Sub
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
' Verifies that the control is rendered
End Sub
Private Sub BindGrid()
'Dim dt As DataTable = CType(Session("dtCart"), DataTable)
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn(2) {
New DataColumn("Id"),
New DataColumn("Name"),
New DataColumn("Country")})
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Response.Redirect("~/Inventaire.aspx")
End Sub