Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 .....

XML
<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.

XML
<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

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!
 
Share this answer
 
Submit Answers Fast














;dgldg
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900