i have gridview in whict three column ,rate and Quantity column and Total amount shoukd show in third column called Total which is Label item template.
I want do this by using java scripts
<asp:GridView ID="gvWetFlyAshDtls" runat="server" AutoGenerateColumns="false" OnRowCommand="gvWetFlyAshDtls_RowCommand" OnRowEditing="gvWetFlyAshDtls_RowEditing" Style="border-collapse: collapse; width: 50%; margin: 0 auto;"> <Columns>
<asp:TemplateField HeaderText="Wet Fly Ash Category"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> <ItemTemplate> <asp:Label ID="lblWet_Fly_Param" runat="server" Text='<%#Eval("WetFlyParam")%>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Trip"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> <ItemTemplate>
<asp:TextBox ID="txttrip" runat="server" Text='<%#Eval("Qunatity")%>' onkeyup="startCalc(this.value)"></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Quantity(MT)"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> <ItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Text='<%#Eval("Qunatity")%>' onkeyup="startCalc(this.value)"></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Eqiv Dry Wt"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> <ItemTemplate>
<asp:Label ID="lblEqivdrywet" runat="server" ></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Edit" Visible="false"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> <ItemTemplate> <asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandArgument='<%# Eval("WetFlyID") %>' CommandName="EditWetFly"></asp:LinkButton>
</ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
---------------------------------------------
<script type="text/javascript">
function startCalc() { var grid = document.getElementById("<%= gvWetFlyAshDtls.ClientID%>"); for (var i = 0; i < grid.rows.length - 1; i++) { var trip = $("input[id*=txttrip]"); var qty = $("input[id*=txtQuantity]"); var totalamount = trip[i].value * qty[i].value; $("input[id*=lblEqivdrywet]") = totalamount[i].value; // alert(trip[i].value * qty[i].value); }
} </script>