title: Delete Button/Function deletes the wrong data on SQL
body: <p>I'm using Visual Studio 2012 backed-up by SQL Server Management Studio as its database. I'm using a gridview to see my data. I used a TemplateField I can both edit and delete a data. But it seems that when I'm deleting a certain data, it always delete the first data. What might be the solution?</p>
  
  <p>Here is my asp code:</p>
  
  <pre><code>&lt;asp:Content ID="Content4" ContentPlaceHolderID="full_main" Runat="Server"&gt;
      &lt;asp:GridView ID="gvUsers" runat="server" 
      class="table table-bordered data-table" AutoGenerateColumns="False" 
      AllowPaging="True" onpageindexchanging="gvUsers_PageIndexChanging" 
          onselectedindexchanged="gvUsers_SelectedIndexChanged" EnableModelValidation="True"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="UserID" HeaderText="User ID" InsertVisible="False" 
                  ReadOnly="True" SortExpression="UserID" /&gt;
              &lt;asp:BoundField DataField="FirstName" HeaderText="First Name" 
                  SortExpression="FirstName" /&gt;
              &lt;asp:BoundField DataField="LastName" HeaderText="Last Name" 
                  SortExpression="LastName" /&gt;
              &lt;asp:BoundField DataField="EmailAddress" HeaderText="Email Adress" SortExpression="EmailAddress" /&gt;
              &lt;asp:BoundField DataField="Street" HeaderText="Street" SortExpression="Street" /&gt;
              &lt;asp:BoundField DataField="Municipality" HeaderText="Municipality" SortExpression="Municipality" /&gt;
              &lt;asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /&gt;
              &lt;asp:BoundField DataField="ZipCode" HeaderText="Zip Code" SortExpression="ZipCode" /&gt;
              &lt;asp:BoundField DataField="ContactNo" HeaderText="Contact No" SortExpression="ContactNo" /&gt;
              &lt;asp:TemplateField HeaderText="Actions"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;a href="http://localhost:12345/CAPSTONE/Users/Edit.aspx?ID=&lt;%# Eval("UserID") %&gt;" 
                                  class="btn btn-primary btn-mini"&gt;Edit&lt;/a&gt;
                              &lt;a href="#deleteItem" data-toggle="modal" class="btn btn-danger btn-mini"&gt;Delete&lt;/a&gt;
                              &lt;div id="deleteItem" class="modal hide"&gt;
                                &lt;div class="modal-header"&gt;
                                  &lt;button data-dismiss="modal" class="close" type="button"&gt;×&lt;/button&gt;
                                  &lt;h3&gt;Record Deletion&lt;/h3&gt;
                                &lt;/div&gt;
                                &lt;div class="modal-body"&gt;
                                  &lt;p&gt;Are you sure you want to delete the record?&lt;/p&gt;
                                &lt;/div&gt;
                                &lt;div class="modal-footer"&gt; 
                                  &lt;a class="btn btn-primary"
                                      href="http://localhost:12345/CAPSTONE/Users/Delete.aspx?ID=&lt;%# Eval("UserID") %&gt;"&gt;Confirm&lt;/a&gt; 
                                  &lt;a data-dismiss="modal" class="btn" href="#"&gt;Cancel&lt;/a&gt; 
                                &lt;/div&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
          &lt;EmptyDataTemplate&gt;
              &lt;center&gt;
                  &lt;h1&gt;
                      No records found.&lt;/h1&gt;
              &lt;/center&gt;
          &lt;/EmptyDataTemplate&gt;
          &lt;PagerStyle CssClass="pagination alternate" /&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is my code behind:</p>
  
  <pre><code>void DeleteUser(int userID)
      {
          con.Open();
          SqlCommand cmd = new SqlCommand();
          cmd.Connection = con;
          cmd.CommandText = "DELETE FROM Users WHERE UserID=@UserID";
          cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = userID;
          cmd.ExecuteNonQuery();
          con.Close();
          Helper.AddLog(Session["userid"].ToString(), "Delete", "Deleted a User");
          Response.Redirect("Default.aspx");
      }
  </code></pre>