<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
function Print(a) {
var row = $(a).closest("tr").clone(true);
var printWin = window.open('', '', 'left=0", ",top=0,width=1000,height=600,status=0');
var table = $("[id*=GridView]").clone(true);
$("tr", table).not($("tr:first-child", table)).remove();
table.append(row);
$("tr td:last,tr th:last", table).remove();
var dv = $("<div />");
dv.append(table);
printWin.document.write(dv.html());
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" GridLines="Both">
<Columns>
<asp:BoundField DataField="Item" ItemStyle-Width="100" HeaderText="Item" />
<asp:BoundField DataField="Price" ItemStyle-Width="100" HeaderText="Price" />
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:;" onclick="Print(this)">Print</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Item"), new DataColumn("Price") });
dt.Rows.Add("Shirt", 199);
dt.Rows.Add("Football", 20);
dt.Rows.Add("Shirt", 22.5);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
Demo