Click here to Skip to main content
12,501,845 members (52,425 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET Javascript Gridview , +
Hello Friends, have a good day !!

am working on asp.net Gridview i want to print the Gridview data its working fine.
I have a select button at the left side of gridview, I mean GridView1_SelectedIndexChanged(object sender, EventArgs e)through this i can select particular row in another page. its fine But the thing is .....

<Columns>
<asp:CommandField ShowSelectButton="True" />
   </Columns>


While printing Gridviewcommand Field button(Select) is also printing.

So how to hide that Select button


This is my javascript for printing its working fine.

<script type="text/javascript">
function PrintGridData() {
var prtGrid = document.getElementById('<%=GridView1.ClientID %>');
prtGrid.border = 0;
var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
var logoData="";
prtwin.document.write("<div align='center'><span style='color:#00671A;font-family:Arial, Helvetica, sans-serif;font-weight:bold;font-size:22px;align;text-align:center'>Users Information </span><br/><br/><span style='color:#00671A;font-family:Arial, Helvetica, sans-serif;font-weight:bold;font-size:22px;align;text-align:center'>Current Records </span><br/><br/></div>");
prtwin.document.write(prtGrid.outerHTML);
prtwin.document.close();
prtwin.focus();
prtwin.print();
prtwin.close();
}
 
</script>



<input type="button" id="btnPrint" value="Print" onclick="PrintGridData()" />


So, how to hide select button from Gridview while printing..Please help Thanks.....
Posted 18-Jan-13 19:37pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Make the button Visible = false inside the GridView in aspx page. So now while printing the grid won't show up the button.

Make the button visible = true in the code behind while loading the grid.

Try it out!
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Submit Answers Fast














;dgldg
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100