< script type = "text/javascript" > |
$(function() { |
//event handler to the checkbox selection change event |
$("input[type=checkbox]").change(function() { |
//variables to store the total price of selected rows |
//and to hold the reference to the current checkbox control |
var totalPrice = 0, ctlPrice; |
//iterate through all the rows of the gridview |
$('#gvProducts tr').each(function() { |
//if the checkbox in that rows is checked, add price to our total proce |
if ($(this).find('input:checkbox').attr("checked")) { |
ctlPrice = $(this).find('[id$= lblamount]'); |
//since it is a currency column, we need to remove the $ sign and then convert it |
//to a number before adding it to the total |
totalPrice += parseFloat(ctlPrice.text().replace(/[^\d\.]/g, '')); |
} |
}); |
//finally set the total price (rounded to 2 decimals) to the total paragraph control. |
$('#lblTotal').text("$ " + totalPrice.toFixed(2)); |
}); |
}); |
</ script > |
--------------------------------------------------------------
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox runat="server" ID="chkHeader" Checked="true" OnCheckedChanged="chkHeader_CheckedChanged"
AutoPostBack="true" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chk_shouldinsert" runat="server" Checked="true" ClientIDMode="Static"
CssClass="chkClass" />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lbltxttotal" runat="server" Text="Total" />
</FooterTemplate>
</asp:TemplateField>
--------------------------------------------------------------
<asp:TemplateField HeaderText="CheckUp Amount">
<ItemTemplate>
<asp:Label ID="lblamount" runat="server" Text='<%# Eval("CD_SELLING_PRICE") %>' ClientIDMode="Static" />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotal" runat="server" ClientIDMode="Static" />
</FooterTemplate>
</asp:TemplateField>
No comments:
Post a Comment