i did'nt get the appropriate code to print my griddata in other page while i click the print button
so kindly send me the code for to my problem..
thank you...
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Happy MakwanaPosted Apr 17, 2015, 4:00 AM
protected void btnPrintData_Click(object sender, EventArgs e)
{
GridView1.PagerSettings.Visible = false;
GridView1.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.RenderControl(hw);
string gridHTML = sw.ToString().Replace("\"", "'")
.Replace(System.Environment.NewLine, "");
StringBuilder sb = new StringBuilder();
sb.Append("");
ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
GridView1.PagerSettings.Visible = true;
GridView1.DataBind();
}
}
John BhattPosted Sep 16, 2013, 8:44 AM
You want to print only Gridview not entire page.
Solution is, put Gridview inside a Panel as below:
............
..............
............
Now create a function as below:
function CallPrint()
{
var printContent = document.getElementById('<%= pnlToPrint.ClientID %>');
var printWindow = window.open("", "Print Panel", 'left=50000,top=50000,width=0,height=0');
printWindow.document.write(prtContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}
Refer to this thread for more details:
http://www.codeproject.com/Questions/404530/print-Gridview-data
All the Best.
Sanjeeb LenkaPosted Sep 15, 2013, 2:22 PM
try this link
http://www.aspdotnet-suresh.com/2012/10/print-aspnet-gridview-data-using-c.html