Posted on 2004-11-30
Last Modified: 2010-04-23
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?
Question by:Donnie4572
    LVL 1

    Expert Comment

    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?
    LVL 12

    Author Comment

    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,
    LVL 1

    Accepted Solution

    LVL 12

    Author Comment

    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="">
                <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 ="","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>

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now