title: Auto multiply two column in gridview
body: <p>HI,</p>
  
  <p>I need to calculate values of two textboxex in gridview and display the result in the third textbox using javascript as soon as the value entered in second textbox.</p>
  
  <p>my textbox fields are: Quantity and Price
  The result should be displayed in Total.</p>
  
  <p>that is, (Total)Value= Quantity * Rate.</p>
  
  <p>I have tried this,
  CODE BEHIND:C#</p>
  
  <pre><code>protected void gvPOItms__RowCreated(Object sender, GridViewRowEventArgs e)
  {
      try
      {            
          TextBox txt1 = (TextBox)e.Row.FindControl("txtQty");
          TextBox txt2 = (TextBox)e.Row.FindControl("txtRate");
          TextBox txt3 = (TextBox)e.Row.FindControl("txtValue");
  
          txt1.Attributes["onKeyup"] = "javascript: return multiplication('" + txt1.ClientID + "','" + txt2.ClientID + "','" + txt3.ClientID + "')";
          txt2.Attributes["onKeyup"] = "javascript: return multiplication('" + txt1.ClientID + "','" + txt2.ClientID + "','" + txt3.ClientID + "')";
      }
      catch (Exception ex)
      {
          Response.Write(ex);
      }
  }
  </code></pre>
  
  <p>JAVASCRIPT:</p>
  
  <pre><code>&lt;Script type="text/javascript"&gt;
   function multiplication(tx1,txt2,txt3)
          {
          //Your logic for multiplication
          var Qty=document.getElementById(txt1).value;
          var Rate=document.getElementById(txt2).value;
          document.getElementById(txt3).value=Qty*Rate;       
          }
      &lt;/script&gt; 
  </code></pre>
  
  <p>Markup Page:</p>
  
  <p>
                          
                          
                              
                          
                          </p>
  
  <p>
                          
                              
                          
                           </p>
  
  <p>
                          
                             
                          
                           
   </p>
  
  <p>But, i couldn't get the answer, its not throwing any error.</p>
  
  <p>Can someone tell me what's wrong?</p>