Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > printing gridview

Reply
Thread Tools

printing gridview

 
 
=?Utf-8?B?Vmlua2k=?=
Guest
Posts: n/a
 
      10-26-2007
Hello Everyone,

I am trying to print a gridview. I have a print button on my aspx page.
Below is the javascript code

function CallPrint( strid )
{
var prtContent = document.getElementById( strid );
var WinPrint = window.open('', '',
'left=0,top=0,width=1050,height=600,toolbar=1,scro llbars=1,status=0');
WinPrint.document.write( prtContent.innerHTML );
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
// prtContent.innerHTML=strOldOne;
}

<asp:Button ID="btnPrint" runat="server" Text="Print the Grid"
OnClick="btnPrint_Click" Style="position: static" />

Inside the aspx.cs page, i have
btnPrint.Attributes["onclick"] = "javascript:CallPrint('print_Grid');";

and my gridview is inside the <div> tag

<div id="print_Grid">
gridview - that needed to be printed

</div>

I have two questions:

1) I can print the grid view but not all the columns are coming in the
printout. Last 10 columns of the aspx screen are cutoff from the printout. Is
it possible to printout and see all the columns. I tried landscpae view, but
still all the columns are not coming in the print out.
2) can I get the header of the gridview in every printout.

Please let me know if it possible

Thanks.








 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJhdWxpbyBEaWV6?=
Guest
Posts: n/a
 
      10-26-2007
Vinki,

Printing a gridView from an ASP .net page can become a nightmare. I would
rather let the user export the grid into excel so he can configure the output
using a powerful Office product like Ms Excel.

A fast way to export a grid view to Excel (no extra code from your side
needed, just use this free source code):

http://www.dotnetjohn.com/articles.aspx?articleid=231

Good luck,
Braulio

PS: More info about ASP .net and Excel Export:

http://www.tipsdotnet.com/ArticleBlo...el&PageIndex=0

More info about ASP .net Gridview:

http://www.tipsdotnet.com/ArticleBlo...ew&PageIndex=0

/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------




"Vinki" wrote:

> Hello Everyone,
>
> I am trying to print a gridview. I have a print button on my aspx page.
> Below is the javascript code
>
> function CallPrint( strid )
> {
> var prtContent = document.getElementById( strid );
> var WinPrint = window.open('', '',
> 'left=0,top=0,width=1050,height=600,toolbar=1,scro llbars=1,status=0');
> WinPrint.document.write( prtContent.innerHTML );
> WinPrint.document.close();
> WinPrint.focus();
> WinPrint.print();
> WinPrint.close();
> // prtContent.innerHTML=strOldOne;
> }
>
> <asp:Button ID="btnPrint" runat="server" Text="Print the Grid"
> OnClick="btnPrint_Click" Style="position: static" />
>
> Inside the aspx.cs page, i have
> btnPrint.Attributes["onclick"] = "javascript:CallPrint('print_Grid');";
>
> and my gridview is inside the <div> tag
>
> <div id="print_Grid">
> gridview - that needed to be printed
>
> </div>
>
> I have two questions:
>
> 1) I can print the grid view but not all the columns are coming in the
> printout. Last 10 columns of the aspx screen are cutoff from the printout. Is
> it possible to printout and see all the columns. I tried landscpae view, but
> still all the columns are not coming in the print out.
> 2) can I get the header of the gridview in every printout.
>
> Please let me know if it possible
>
> Thanks.
>
>
>
>
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 2 11-27-2010 12:12 PM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:52 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM



Advertisments