Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre lang="text"><pre lang="text">
i want to compare the gridview textbox value of same row on keyup event of txtdile_order but the javascript code not give the output.

My grid view is

<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" style="table-layout:auto;text-align:left;" BorderStyle="None" BorderWidth="1px" CellPadding="4" Height="125px" Width="1037px" ShowFooter="True" OnRowDataBound="gv_RowDataBound">
                        <asp:BoundField HeaderText="S No." DataField="rownum" />
                        <asp:BoundField HeaderText="Product Code" DataField="product_code" />
                        <asp:BoundField HeaderText="Ordered Quantity" DataField="quantity" />

                        <asp:TemplateField HeaderText="Deliver Order">
                             <asp:TextBox ID="txtdile_order" runat="server" BackColor="#ffff99" OnKeyUP="return GetTotal2(this)" Text='<%# Bind("quantity_sale") %>' AutoPostBack="true"></asp:TextBox>

                            <asp:TextBox ID="txtdile_Total" runat="server"  BackColor="#66ff33"></asp:TextBox>

                            <%--<ItemStyle BackColor="Yellow" />--%>
                        <asp:TemplateField HeaderText="Dealer Value">
                             <asp:TextBox ID="txtdeal" runat="server" BackColor="#cccccc" ReadOnly="true" Text='<%# Bind("dealer_value") %>'  AutoPostBack="false" ></asp:TextBox>

                        <asp:TemplateField HeaderText="Sub Total">

                             <asp:TextBox ID="txtsub_total" runat="server" BackColor="#cccccc" ReadOnly="true" Text='<%# Bind("sub_total") %>'  AutoPostBack="false"></asp:TextBox>

                            <asp:TextBox ID="txtFootTotal" runat="server" BackColor="#66ff33"></asp:TextBox>

                        <asp:BoundField HeaderText="UOM" DataField="uom" />
                        <asp:BoundField HeaderText="Available Quantity" DataField="avquantity" />
                      <asp:TemplateField HeaderText="Available Quantity1">
                             <asp:TextBox ID="lblav" runat="server" AutoPostBack ="false"  ReadOnly ="true" Text='<%# Bind("avquantity") %>'></asp:TextBox>


                    <FooterStyle BackColor="#ac0e14" ForeColor="#330099" />
                    <HeaderStyle BackColor="#ac0e14" Font-Bold="True" ForeColor="#FFFFff" />


my code is
<pre lang="cs">function GetTotal2(lnk) {
         var row = lnk.parentNode.parentNode;
         var rowIndex = row.rowIndex - 1;

         i = rowIndex;

         var grid = document.getElementById(&quot;&lt;%= gv.ClientID%&gt;&quot;);
         var inputs = grid.getElementsByTagName(&quot;input&quot;);

         var x =0;
         var y = 0;

         if (inputs[i].name.indexOf(&quot;lblav&quot;) &gt; 1) {
                 //if (inputs[i].value != &quot;&quot;) {
                     x =  parseInt(inputs[i].value);


                 if (inputs[i].name.indexOf(&quot;txtdile_order&quot;) &gt; 1) {
                     //if (inputs[i].value != &quot;&quot;) {
                         y = parseInt(inputs[i].value);


             alert(&quot;Check the Avaibility Of Stock&quot;);
             return true;

         return false;


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900