my html to get total in gridview is
<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*=txtQuantity]").val("0");
});
$("[id*=txtQuantity]").live("keyup", function () {
if (isNaN(parseInt($(this).val()))) {
$(this).val('0');
} else {
$(this).val(parseInt($(this).val()).toString());
}
});
$("[id*=txtQuantity]").live("keyup", function () {
if (!jQuery.trim($(this).val()) == '') {
if (!isNaN(parseFloat($(this).val()))) {
var row = $(this).closest("tr");
$("[id*=lblTotal]", row).html(parseFloat($(".price", row).html()) * parseFloat($(this).val()));
}
} else {
$(this).val('');
}
/*var totalQuantity = 0;
$("[id*=txtQuantity]").each(function () {
totalQuantity = totalQuantity + parseInt($(this).val());
});
$("[id*=lblTotalQuantity]").html(totalQuantity.toString()); */
var grandTotal = 0;
$("[id*=lblTotal]").each(function () {
grandTotal = grandTotal + parseFloat($(this).html());
//grandTotal = grandTotal +grandTotal;
});
$("[id*=lblGrandTotal]").html(grandTotal.toString());
});
</script>
my code to save data in database is
foreach (GridViewRow row in gvSelected.Rows)
{
string Inv = txtNo.Text.Trim();
DateTime SDate = DateTime.Now;
Label Code = row.FindControl("lblCode") as Label;
string Qty = (row.FindControl("txtQuantity") as TextBox).Text;
Label Tot = row.FindControl("lblTotal") as Label;
con.SqlQuery("Insert Into tblItemSold (InvoiceNo,ItemCode,Price,Quantity,GrandTotal,SDate) VALUES (@Inv,@Code,@Price,@Qty,@GT,@Date)");
con.Cmd.Parameters.AddWithValue("@Inv", Inv);
con.Cmd.Parameters.AddWithValue("@Code", Code.Text);
con.Cmd.Parameters.AddWithValue("@Price", row.Cells[2].Text);
con.Cmd.Parameters.AddWithValue("@Qty", Qty);
con.Cmd.Parameters.AddWithValue("@GT", Tot.Text);
con.Cmd.Parameters.AddWithValue("@Date", SDate.ToString("dd.MM.yyyy"));
con.NonQueryEx();
}
it is not inserting Column value of Name Total. Pic is attached