This Way:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=txtPrice5]").val("0");
});
$("[id*=txtPrice5]").live("change", function () {
if (isNaN(parseInt($(this).val()))) {
$(this).val('0');
} else {
$(this).val(parseInt($(this).val()).toString());
}
});
$("[id*=txtPrice5]").live("keyup", function () {
if (!jQuery.trim($(this).val()) == '') {
if (!isNaN(parseFloat($(this).val()))) {
var row = $(this).closest("tr");
var number = parseFloat($("[id*=txtPrice1]", row).val());
$("[id*=lblTotal]", row).html(parseFloat($("[id*=txtPrice1]", row).val()) + parseFloat($("[id*=txtPrice2]", row).val()) + parseFloat($("[id*=txtPrice3]", row).val()) + parseFloat($("[id*=txtPrice4]", row).val()) + parseFloat($(this).val()));
}
} else {
$(this).val('');
}
var grandTotal = 0;
$("[id*=lblTotal]").each(function () {
grandTotal = grandTotal + parseFloat($(this).html());
});
$("[id*=lblGrandTotal]").html(grandTotal.toString());
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Item" HeaderText="Item" />
<asp:TemplateField HeaderText="Price1">
<ItemTemplate>
<asp:TextBox ID="txtPrice1" runat="server" Text='<%# Eval("Price") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price2">
<ItemTemplate>
<asp:TextBox ID="txtPrice2" Text='<%# Eval("Price") %>' runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price3">
<ItemTemplate>
<asp:TextBox ID="txtPrice3" runat="server" Text='<%# Eval("Price") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price4">
<ItemTemplate>
<asp:TextBox ID="txtPrice4" runat="server" Text='<%# Eval("Price") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price5">
<ItemTemplate>
<asp:TextBox ID="txtPrice5" runat="server" Text='<%# Eval("Price") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total">
<ItemTemplate>
<asp:Label ID="lblTotal" runat="server" Text="0"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Grand Total:
<asp:Label ID="lblGrandTotal" runat="server" Text="0"></asp:Label>
</form>
</body>
</html>
C#:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Item"), new DataColumn("Price") });
dt.Rows.Add("Shirt", 0);
dt.Rows.Add("Football", 0);
dt.Rows.Add("Bat", 0);
GridView1.DataSource = dt;
GridView1.DataBind();
}
Ref:Calculate Running Total in ASP.Net GridView using jQuery
Output: