title: ASP.NET gridview row onclick
body: <p>I'm attempting to have an onclick event added to a row once the data is bound to a gridview webcontrol. The code below is not adding any attributes (checked the viewsource once the page is created) and, of course, no functionality is added. Right now, I've just got the onclick printing to the page, but eventually it will link to another page. Any ideas on what's wrong?</p>
  
  <p>Also, thanks to the stackoverflow community at large. This community has always been a great help. Plan to go through some posts myself this weekend and start answering questions as I can to give back a bit.</p>
  
  <p>C# server-side</p>
  
  <pre><code>protected void dataTbl_RowDataBound(GridViewRowEventArgs e){
              e.Row.Attributes.Add("id",e.Row.Cells[0].Text);
              e.Row.Attributes.Add("onclick", "rowClick('"+e.Row.RowIndex+"')");
  
          }
  </code></pre>
  
  <p>Javascript client-side</p>
  
  <pre><code>function rowClicked(counter){
      document.write(counter);
  }
  </code></pre>