title: How to I call a javascript function on onrowcommand?
body: <p>Using asp.net, c# 3.5, vs 2008. </p>
  
  <p>I have an aspx gridview called gv1 with a working c# codebehind <strong>onrowcommand</strong> method which is called when a button on the row is clicked. </p>
  
  <p>The button on the gridview is being dynamically generated.</p>
  
  <p>I am trying to replace that codebehind call with a javascript function to avoid a roundtrip to the server.  </p>
  
  <p>How do I do this?</p>
  
  <p>So far I have tried  </p>
  
  <ol>
  <li><p>adding a row attribute in the code behind when I am dynamically generating the button in a foreach loop , which didnt work:       </p>
  
  <p>r.Attributes.Add("OnRowCommand", "javascript:gv1RowCommand(ID);"); </p></li>
  <li><p>the following which gives an error before running: no overloaded method takes 1 arg </p>
  
  <pre><code>&lt;asp:GridView ID="gv1" runat="server" onrowcommand="gv1RowCommand(ID)" ...
  </code></pre></li>
  <li><p>various other things such as event <code>onchange , onselected</code> </p></li>
  </ol>
  
  <p>I am using the follow javascript just to see if I can get it to be called:</p>
  
  <pre><code>function gv1RowCommand(ID) { 
  alert(
  "row command"); 
  }
  </code></pre>