Click here to Skip to main content
15,917,565 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to print datagridview value and textbox value ?
Posted
Updated 26-Dec-12 2:08am
v2

Hi,

For printing the textbox value you can use
Response.Write(txtdemo.Text);

For printing the gridview you need to do like this:

put an html button on that page that says print and tie it to a javascript function then have that function open a new window and write the gridview to it then print?
XML
<input id="prtButton" type="button" value="Print" onclick="CallPrint('<%= GridView1.ClientID %>');" />



XML
<script language="javascript" type="text/javascript">
 function CallPrint( strid )
   {
    var prtContent = document.getElementById( strid );
    var WinPrint = window.open('', '', 'left=0,top=0,width=1050,height=600,toolbar=1,scrollbars=1,status=0');
    WinPrint.document.write( prtContent.innerHTML );
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
    WinPrint.close();
   }
</script>


Thanks
 
Share this answer
 
Comments
krishnan12490 27-Jun-13 9:09am    
how to get print only a datagridview in form using windows application c#
 
Share this answer
 
 
Share this answer
 
v2

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