title: ASP.NET Printing Page
body: <pre><code>    &lt;%@ Page Title="" Language="C#"MasterPageFile="~/MasterPage/AdminMaster.master" AutoEventWireup="true"  CodeFile="DemoReport.aspx.cs" Inherits="Reports_DemoReport" %&gt;
      &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %&gt;
                &lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt;
          &lt;script  type="text/javascript"&gt;
          function CallPrint(strid) {
              var prtContent = document.getElementById(strid);
              var strOldOne = prtContent.innerHTML;
              var WinPrint = window.open('', '', 'letf=0,top=0,width=600,height=400,toolbar=0,scrollbars=0,status=0');
              WinPrint.document.write(prtContent.innerHTML);
              WinPrint.document.close();
              WinPrint.focus();
              WinPrint.print();
              WinPrint.close();
          }
  &lt;/script&gt;
          &lt;div&gt;
          &lt;fieldset&gt;
              &lt;legend&gt;Search Date Wise&lt;/legend&gt;
              &lt;table class="auto-style1"&gt;
                  &lt;tr&gt;
  
                      &lt;td&gt;From Date&lt;/td&gt;
                      &lt;td&gt;:&lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:TextBox runat="server" ID="txtFromDate" Width="100px"&gt;&lt;/asp:TextBox&gt;
                          &amp;nbsp;&lt;asp:ImageButton runat="server" ID="imgFromDate" ImageUrl="~/_images/Calendar.gif" AlternateText="FromDate" /&gt;
                          &lt;asp:CalendarExtender ID="dtpFromDate" runat="server" CssClass=" cal_Theme1" TargetControlID="txtFromDate"
                              Format="MM/dd/yyyy" PopupButtonID="imgFromDate" PopupPosition="BottomLeft" /&gt;
                      &lt;/td&gt;
                      &lt;td&gt;To Date&lt;/td&gt;
                      &lt;td&gt;:&lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:TextBox runat="server" ID="txtToDate" Width="100px"&gt;&lt;/asp:TextBox&gt;
                          &amp;nbsp;&lt;asp:ImageButton runat="server" ID="imgTodate" ImageUrl="~/_images/Calendar.gif" AlternateText="ToDate" /&gt;
                          &lt;asp:CalendarExtender ID="CalendarExtender1" runat="server" CssClass=" cal_Theme1" TargetControlID="txtToDate"
                              Format="MM/dd/yyyy" PopupButtonID="imgTodate" PopupPosition="BottomLeft" /&gt;
                      &lt;/td&gt;
  
                      &lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;asp:Button ID="btnGO" Text="GO" runat="server" Width="80px" OnClick="btnGO_Click" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;asp:Button ID="btnPrint" runat="server" Text="Print" Width="80px" OnClientClick="CallPrint('printDIV');" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/fieldset&gt;
      &lt;/div&gt;
  
          &lt;div id="printDIV"&gt;
          &lt;fieldset&gt;
              &lt;legend&gt;Complain Histroy&lt;/legend&gt;
  
              &lt;asp:GridView ID="GridView1" runat="server" Width="1250px" AutoGenerateColumns="False" CellPadding="4" EnableModelValidation="True" ForeColor="Black" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellSpacing="2"&gt;
                  &lt;FooterStyle BackColor="#CCCCCC" /&gt;
                  &lt;HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /&gt;
                  &lt;PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" /&gt;
                  &lt;RowStyle BackColor="White" /&gt;
                  &lt;SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /&gt;
             &lt;Columns&gt;
                 &lt;asp:TemplateField HeaderText="Date" ItemStyle-HorizontalAlign="Center"&gt;
                     &lt;ItemTemplate&gt;
                         &lt;%#Eval("CurrentDate") %&gt;
                     &lt;/ItemTemplate&gt;
  
  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                 &lt;/asp:TemplateField&gt;
  
                  &lt;asp:TemplateField HeaderText="Superviser" ItemStyle-HorizontalAlign="Center"&gt;
                     &lt;ItemTemplate&gt;
                         &lt;%#Eval("SUPERVISER") %&gt;
                     &lt;/ItemTemplate&gt;
  
  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                 &lt;/asp:TemplateField&gt;
  
                  &lt;asp:TemplateField HeaderText="QuarterNo" ItemStyle-HorizontalAlign="Center"&gt;
                     &lt;ItemTemplate&gt;
                         &lt;%#Eval("QNUMBER") %&gt;
                     &lt;/ItemTemplate&gt;
  
  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                 &lt;/asp:TemplateField&gt;
  
                  &lt;asp:TemplateField HeaderText="AcknowledgementKey" ItemStyle-HorizontalAlign="Center"&gt;
                     &lt;ItemTemplate&gt;
                         &lt;%#Eval(" ACKEY") %&gt;
                     &lt;/ItemTemplate&gt;
  
  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                 &lt;/asp:TemplateField&gt;
  
                  &lt;asp:TemplateField HeaderText="ComplainKey" ItemStyle-HorizontalAlign="Center"&gt;
                     &lt;ItemTemplate&gt;
                         &lt;%#Eval("COMPKEY") %&gt;
                     &lt;/ItemTemplate&gt;
  
  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                 &lt;/asp:TemplateField&gt;
  
                  &lt;asp:TemplateField HeaderText="Status" ItemStyle-HorizontalAlign="Center"&gt;
                     &lt;ItemTemplate&gt;
                         &lt;%#Eval("STATUS") %&gt;
                     &lt;/ItemTemplate&gt;
  
  &lt;ItemStyle HorizontalAlign="Center"&gt;&lt;/ItemStyle&gt;
                 &lt;/asp:TemplateField&gt;
  
             &lt;/Columns&gt;
  
                   &lt;/asp:GridView&gt;
          &lt;/fieldset&gt;
      &lt;/div&gt;
  
  
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>I have to print only the grid view that is on the page , Printing is working fine but I want to generate dynamic header/footer on the print page.
  How I can achieve that. I am generally from java back ground so please if you are writing code make it less complicated. 
  Thanks for your time consideration.</p>