Try this jscript...
<script type="text/javascript">
function printGrid() {
var gridData = document.getElementById('<%= yourForm.yourformID %>');
var windowUrl = 'Youraspxfilename.aspx';
//set print document name for gridview
var uniqueName = new Date();
var windowName = 'Print_' + uniqueName.getTime();
var prtWindow = window.open(windowUrl, windowName,
'left=100,top=100,right=100,bottom=100,width=700,height=500');
prtWindow.document.write('<html><head></head>');
prtWindow.document.write('<body style="background:none !important">');
prtWindow.document.write(gridData.outerHTML);
prtWindow.document.write('</body></html>');
prtWindow.document.close();
prtWindow.focus();
prtWindow.print();
prtWindow.close();
}
</script>
Try this print button in Aspx file...
<div class="form-group col-md-4">
<asp:Button ID="btnPrint" runat="server" Text="Print Data" OnClientClick="printGrid()" /> <asp:Button ID="btnPrintFromCodeBehind" runat="server" Text="Print From" OnClick="btnPrintFromCodeBehind_Click" Visible="false" />
</div>
C# code...
protected void btnPrintFromCodeBehind_Click(object sender, EventArgs e)
{
try
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "printGrid", "printGrid();", true);
}
catch
{
}
}