title: asp:Button inside SharePoint Dataview Rows with onclick event does not call C# function. Pull it out of Dataview and works fine
body: <p>asp:Button inside SharePoint Dataview Rows with onclick event does not call C# function. Pull it out of Dataview and works fine.</p>
  
  <p>I have a ASP.NET Button I've placed inside a SharePoint  DataView's rows with an onclick event pointing to C# function block inside my page. The page refreshes when I click on them, but it's not hitting that code block. If I move the button to outside the dataview and make the ID fixed, the code works beautifully. what's up with that?</p>
  
  <p>the button in the Dataview:</p>
  
  <pre><code>&lt;asp:Button runat="server" Text="Delete" id="Delete{@ID}" CommandArgument="{@FileRef}" OnClick="DeleteDoc"/&gt;
  </code></pre>
  
  <p>my C# onclick handler (inline C# on the page)</p>
  
  <pre><code>void DeleteDoc(object sender, EventArgs e){sendmail("DeleteDoc");Button b = sender as button;.. more code
  </code></pre>
  
  <p>This is all inline code and I'm working from SharePoint Designer. Not sure how I can troubleshoot this.</p>
  
  <p>Am I missing something here, maybe I need to add an Itemtemplate or something like we need to in a ASP.NET gridview controls?</p>
  
  <p>Thanks.</p>