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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 15, 2013, 10:22 AM EDT
try this link
http://www.aspdotnet-suresh.com/2012/10/print-aspnet-gridview-data-using-c.html
John BhattRank #1,381 · 1.2K reputationPosted Sep 16, 2013, 4:44 AM EDT
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.
Happy Makwana146 reputationPosted Apr 17, 2015, 12:00 AM EDT
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();
}
}