Click here to Skip to main content
15,879,326 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

XML
<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">
                    <Columns>
                        <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">
                            <ItemTemplate>
                             <asp:TextBox ID="txtdile_order" runat="server" BackColor="#ffff99" OnKeyUP="return GetTotal2(this)" Text='<%# Bind("quantity_sale") %>' AutoPostBack="true"></asp:TextBox>

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

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

                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Sub Total">

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

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

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

                    </Columns>


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

                </asp:GridView>








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

         i = rowIndex;
         alert(i);

         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);
                     alert(x);
                 //}

             }




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

                 }

         if(y&gt;x)
         {
             alert(&quot;Check the Avaibility Of Stock&quot;);
             return true;
         }

         return false;


     }</pre>
Posted

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