Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7658387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:11:42+00:00 2026-05-31T13:11:42+00:00

I am making a gridview which uses scrolling as the column are a more

  • 0

I am making a gridview which uses scrolling as the column are a more than the page width of my webpage .
The issue is when i want to print it only prints the shown data. How can i print everything in a div or panel ?

MY CODE FOR GRIDVIEW:

<a href="#" onclick="printPartOfPage('content-middle')" >PRINT ME </a>

<asp:Panel ID="gridPanel" runat="server" Height="500px" Width="980px" ScrollBars="Auto">


   <asp:GridView EnableSortingAndPagingCallbacks="true" Width="450px" 
            OnRowCreated="GridView1_RowCreated" runat="server" ID="GridView2" 
          CellPadding="4" ForeColor="#333333" GridLines="None" 
            >

                 <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

                 <Columns>

                     <asp:HyperLinkField DataNavigateUrlFields="ID" 
                         DataNavigateUrlFormatString="updateAppointmentOperations.aspx?showID={0}" Text="Update " 
                         Target="_blank" />
                 </Columns>

                 <EditRowStyle BackColor="#999999" />
                 <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                 <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                 <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                 <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                 <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                 <SortedAscendingCellStyle BackColor="#E9E7E2" />
                 <SortedAscendingHeaderStyle BackColor="#506C8C" />
                 <SortedDescendingCellStyle BackColor="#FFFDF8" />
                 <SortedDescendingHeaderStyle BackColor="#6F8DAE" />

             </asp:GridView>

    </asp:Panel>

And the javascript print i got of the internet and it is:

<script type="text/javascript">

function printPartOfPage(elementId) {
    var printContent = document.getElementById(elementId);
    var windowUrl = 'about:blank';
    var uniqueName = new Date();
    var windowName = 'Print' + uniqueName.getTime();
    var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');

    printWindow.document.write('<link rel="stylesheet" type="text/css" href="style/additional.css" /><link rel="stylesheet" type="text/css" href="style/default.css" /><link rel="stylesheet" type="text/css" href="style/hi-res.css" />' + printContent.innerHTML);
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();
}

The gridview is in a div with id content middle.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:11:43+00:00Added an answer on May 31, 2026 at 1:11 pm

    You can include another GridView on the page, which will only be used for printing.

    The way to toggle which one is shown is to decorate the two with CSS classes, as appropriate.

    For example:

    <style>
    @media print {
        .PrintOnly { display:block; }
        .ScreenOnly { display:none; }
      }
      @media screen {
        .PrintOnly { display:none; }
        .ScreenOnly { display:block; }
      }
    </style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making Winforms application. I have put gridview in usercontrol. Which is another
I'm trying to sort a gridview with my objectdatasource which uses a function import
I'm working on an ASP.Net page containing a GridView, which is populated with customer
I am making a WebForm in asp.net and I want to display gridview with
I am trying to generate a gridview dynamically through codebehind. So I am making
Making an adobe flex ui in which data that is calculated must use proprietary
I have a gridview and listview in my aspx pages which both display tables
How do I pass a GridView column value to the code behind with out
<asp:GridView ID=GridView3 runat=server Width=100% DataSourceID=SDSAllowPaging=True AutoGenerateColumns=False > <Columns> <asp:BoundField DataField=Hint HeaderText=textSortExpression=Hint /> <asp:BoundField DataField=Visi
I have a very simple mockup I'm making for a client that uses the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.