• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:


VS 2003 Web Application VB.Net
Does anyone know if its possible to print the header row of a datagrid on every page. If so, could you show me how?
  • 2
  • 2
1 Solution
So you've set up your datagrid to do paging with a page size of 50(or whatever) and you want to display the header when you go to items 51 to 100?
Once you click the next page link on your grid the YourGrid_PageIndexChanged event will get fired. You will set up the new page to display, YourGrid.CurrentPageIndex = e.NewPageIndex and then you'll have to rebuild your data that you are binding to your datatable, and bind it.
Is this what you want to do? Am I understanding the problem?
Donnie4572Author Commented:
Sorry I didn't post enough info.
No one wants paging I must set the datagrid to scroll.

header row = name
item row =    user1
item row =    user2
item row =    user3
item row =    user4
item row =    user5
item row =    user6

So, when this datagrid prints it = about 30 pages. Page one has the header row but page 2-30 only show the item rows.

This datagrid is replacing excel spreadsheet which from file, page setup, sheet tab, rows to be repeated. This allowed them to have the header row added to every page that prints.

Thanks for your help,
Donnie4572Author Commented:
I think this is the right direction for me. Only the header row still does not print on every page, using this java. (Header Only Prints On First Page) Could you look at the code.. maybe I missed something. I will just paste my page.

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="try1.aspx.vb" Inherits="print1.try1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
            <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
            <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
            <script language="JavaScript">
var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
     if (document.getElementById != null)
          var html = '<HTML>\n<HEAD>\n';

          if (document.getElementsByTagName != null)
               var headTags = document.getElementsByTagName("head");
               if (headTags.length > 0)
                    html += headTags[0].innerHTML;
          html += '\n</HE>\n<BODY>\n';
          var printReadyElem = document.getElementById("printReady");
          if (printReadyElem != null)
                    html += printReadyElem.innerHTML;
               alert("Could not find the printReady section in the HTML");
          html += '\n</BO>\n</HT>';
          var printWin = window.open("","printSpecial");
          if (gAutoPrint)
          alert("Sorry, the print ready feature is only available in modern browsers.");

      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
                  <input type="button" name="printMe" onClick="printSpecial()" value="Print this Page">
                  <div id="printReady">
                        <asp:DataGrid id=DataGrid1 style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 32px" runat="server" DataSource="<%# ds1 %>" DataKeyField="myID" DataMember="tab1" AutoGenerateColumns="False" Width="550px">
                                    <asp:BoundColumn DataField="numb" SortExpression="numb" HeaderText="numb"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="PoNumb" SortExpression="PoNumb" HeaderText="PoNumb"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="Code" SortExpression="Code" HeaderText="Code"></asp:BoundColumn>

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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