Deleting from SQL detailsView
<p>Hey I am just learning to how to use asp.net and I am trying to use the grid view to display information and details view edit/delete the information from the database.  Right now I can edit and update the information in the database but I also want it to delete and something is not working for me.  I set up an exception and when I select the item and press delete it pops up my exception that another user has deleted the item when it hasn't.  Im not really sure what i have done wrong, to me it looks like it should work.</p>

<p>Here is the code for the delete command and parameters from the details view</p>

<pre><code>      DeleteCommand="DELETE FROM [Customers]
     WHERE [CustomerID] = @original_CustomerID
      AND [Name] = @original_Name
       AND [Address] = @original_Address
        AND [City] = @original_City
         AND [State] = @original_State
          AND [ZipCode] = @original_ZipCode
           AND ([Phone] = @original_Phone 
            OR [Phone] IS NULL  AND @original_Phone IS NULL) 
           AND ([Email] = @original_Email 
           OR [Email] IS NULL AND @original_Email IS NULL)" 

&lt;DeleteParameters&gt;
        &lt;asp:Parameter Name="original_CustomerID" Type="Int32" /&gt;
        &lt;asp:Parameter Name="original_Name" Type="String" /&gt;
        &lt;asp:Parameter Name="original_Address" Type="String" /&gt;
        &lt;asp:Parameter Name="original_City" Type="String" /&gt;
        &lt;asp:Parameter Name="original_State" Type="String" /&gt;
        &lt;asp:Parameter Name="original_ZipCode" Type="String" /&gt;
        &lt;asp:Parameter Name="original_Phone" Type="String" /&gt;
        &lt;asp:Parameter Name="original_Email" Type="String" /&gt;
    &lt;/DeleteParameters&gt;
</code></pre>

<p>and here is the delete functions in the cs file </p>

<pre><code>protected void DetailsView1_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
{
    if (e.Exception != null)
    {
        lblError.Text = "A database error has occurred.&lt;br /&gt;&lt;br /&gt;" +
            "Message: " + e.Exception.Message;
        e.ExceptionHandled = true;
    }
    else if (e.AffectedRows == 0)
        lblError.Text = "Another user may have deleted that customer."
            + "&lt;br /&gt;Please try again.";
    else
        GridView1.DataBind();
}

protected void DetailsView1_ItemDeleting(
    object sender, DetailsViewDeleteEventArgs e)
{
    e.Values["Name"]
        = e.Values["Name"].ToString().Substring(1);
} 
</code></pre>
