How to Hide gridview Allow paging While taking print
I want to hide the allow paging while taking the print out. once the print is taken the the allow paging should view for navigating to the next page. help.....
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 attend4days leftRegister
Javeed M ShaikhRank #839 · 2.7K reputationPosted Nov 10, 2011, 4:58 AM EST
did you try...
before you print..
GridView1.PagerSettings.Visible = false;
after printing is done...
GridView1.PagerSettings.Visible = true;
if the above does not work, try to set the BottomPagerRow.Visible property.
Rajkumar R175 reputationPosted Nov 10, 2011, 7:01 PM EST
Rajkumar R175 reputationPosted Nov 10, 2011, 7:07 PM EST
protected void btnPrint_Click(object sender, EventArgs e)
{
int count = GridView1.PageCount;
if (count == GridView1.PageIndex + 1)
{
GridView1.EmptyDataRowStyle.Font.Bold = true;
GridView1.FooterRow.Visible = true;
}
else
{
GridView1.FooterRow.Visible = false;
}
//GridView1.PagerSettings.Visible = false;
GridView1.AllowPaging = false;
//GridView1.BottomPagerRow.Visible = false;
GridView1.FooterRow.Font.Bold = true;
Response.Write("");
BindGrid();
GridView1.AllowPaging = true;
}
once finally i set as true, paging shown in the printing time also..
please post any help
Javeed M ShaikhRank #839 · 2.7K reputationPosted Nov 11, 2011, 5:35 AM EST
replace with this code and try...
GridView1.AllowPaging = 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.AllowPaging = true;
BindGrid();
You need to override the rendering event also like this, since the .net compiler thinks that the control is not added to the form and is rendered, hence it throws an error even if your GridView control is inside a form with runat = "server".
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}