<asp:GridView ID="GRVItem" DataKeyNames="ItemCode,ItemName" runat="server" Font-Names="Calibri" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" AllowPaging="True" PageSize="5" ShowHeader="true" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" Width="1000px" padding-top=" 70px;" AutoGenerateColumns="false"> <HeaderStyle BorderColor="Gray" BorderStyle="Solid" Font-Bold="true" BackColor="#76C3FD" /> <Columns> <asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="chk" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox_CheckChanged" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField HeaderText="Item Code" DataField="ItemCode" ReadOnly="true" /> <asp:BoundField HeaderText="Item Name" DataField="ItemName" ReadOnly="true" /> <asp:BoundField HeaderText="In Stack" DataField="OnHand" ReadOnly="true" /> <asp:BoundField HeaderText="Price" DataField="AvgPrice" ReadOnly="true" /> <asp:TemplateField HeaderText="Quantity"> <ItemStyle HorizontalAlign="center" Width="13%" /> <HeaderStyle HorizontalAlign="center" /> <ItemTemplate> <asp:TextBox ID="txtQuantity" runat="server" Width="50%"/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Total Price"> <ItemStyle HorizontalAlign="center" Width="13%" /> <HeaderStyle HorizontalAlign="center" /> <ItemTemplate> <asp:Label runat="server" ID="lbltotPrice"></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> function JvfunonBlur() { debugger; var grid = document.getElementById('<%=GRVItem.ClientID %>'); var col1; var totalcol1 = 0; for (i = 0; i < grid.rows.length; i++) { col1 = grid.rows[i].cells[4]; col2 = grid.rows[i].cells[5]; for (j = 0; j < col1.childNodes.length; j++) { if (col1.childNodes[j].type == "text") { if (!isNaN(col1.childNodes[j].value) && col1.childNodes[j].value != "") { totalcol1 += parseInt(col1.childNodes[j].value) } } } } document.getElementById('<%=Price.ClientID %>').value = totalcol1; } Protected Sub GRVItem_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GRVItem.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim txt As Label = DirectCast(e.Row.FindControl("lbltotPrice"), Label) txt.Attributes.Add("onBlur", "JvfunonBlur();") End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)