Last post Jul 24, 2017 06:49 AM by Billy Liu
Jul 21, 2017 01:31 PM|Kvetch|LINK
I'm trying to print all the pages of a paged gridview.
Allow paging is first set to false, the jave script for printing is called, then allow paging is set to true.
However this results in only the current page in the paged gridview being printed.
How do I make it so the gridview is only paged after the print script is called?
protected void printall_Click(object sender, EventArgs e)
GridView1.AllowPaging = false;
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallprintPreviewDiv('Div1')", "printPreviewDiv('Div1')", true);
GridView1.AllowPaging = true;
thanks in advance
Jul 21, 2017 02:54 PM|jimmy69|LINK
your question is not clear sorry i know my english isn't good but i understand you'd like to print all the page of your gridview ?
if yes looks at this sample :
Jul 21, 2017 03:22 PM|KathyW|LINK
"Allow paging is first set to false, the jave script for printing is called, then allow paging is set to true. "
Actually, that is not what you are doing. You are setting paging as false, then saying, "nevermind, it's true". You are databinding the grid twice, but only the last one - where paging is true - counts because you haven't sent the page to the browser yet.
loading. (https://msdn.microsoft.com/en-us/library/z9h4dk8y%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396). In your case, it will execute after
you have loaded the page with the gridview databound after paging is set to true.
The only way to print the whole grid is to send the whole grid down to the browser. You can't do it on the server.
Jul 21, 2017 03:35 PM|Kvetch|LINK
Thanks for your answers. How would I send the whole grid down to the browser? You mean open it in a new window ?
Sorry I'm still not quite familiar with asp.net
Or is there a way to set the page load event so that if the post back is from the print button, then the datagrid.allowpagins is true?
Jul 21, 2017 05:07 PM|PatriceSc|LINK
It seems you want AllowPaging=false to show the whole grid and then print it.
Jul 24, 2017 06:49 AM|Billy Liu|LINK
Do you want to print all pages of gridview?
If their solution is not working, I think you could try to create a new gridview and use js to hide it.
var gridview2 = document.getElementById("GridView2");
gridview2 .style.display = 'none';
Then bind all data to it in your button click event.
Finally, print the new gridview.