views:

181

answers:

1

I have a gridview that i want to print its header on every page and i want to print a page header on every page. The problem is that one or the other works for me. I can't get both to work at the same time. Below is sample code to show what i've done.

<table>
 <tr>
  <td>
  <body onload="thead('tblheader');">
     <table id="tblheader">
        <tr id="title" >
            <td >Page HEADER</td>
        </tr>
     </table>
</body>
   </td>
  </tr>
 <tr>
    <td>
       <body onload="AddTHEAD('claimGrid');">
        <Gridview id="claimGrid"></GridView>
        </body>
     </td>
 </tr>
 </table>

Javascript functions called ---I know both are the exact same i could have just sent the table name, but i had other code in the second functino before.

function AddTHEAD(tableName) {
    var table = $get('<%=claimGrid.ClientID %>');
    if (table != null) {
        var head = document.createElement("THEAD");
        head.style.display = "table-header-group";
        head.appendChild(table.rows[0]);           
        table.insertBefore(head, table.childNodes[0]);
    }
}

function thead(tableName) {
    var table = document.getElementById('tblheader');
    if (table != null) {
        var head = document.createElement("THEAD");
        head.style.display = "table-header-group";
        head.appendChild(table.rows[0]);
        table.insertBefore(head, table.childNodes[0]);
    }
}

CSS class

 <style type="text/css">


@media print
{
    th 
    {
        color:black;
        background-color:white;
    }
    tHead
    {
    display : table-header-group;
    }

}
</style>

what am i doing wrong? if you need more info...just ask

A: 

removed the double body tags and called one function then called the other inside of the first function.

Eric