title: Empty Dictionary Error on Delete with SqlDataSource - ASP.net ListView
body: <p>I'm trying to make a simple ListView with optimistic concurrency. It uses the VS-automatically-generated Delete, Insert, Update statements (except 1 change to insert: see code).
   Insert and Edit work fine and commit to the database. When trying to delete, I get this error:</p>
  
  <h3><em>You have specified that your delete command compares all values on SqlDataSource 'MySourceHere', but the dictionary passed in for values is empty.  Pass in a valid dictionary for delete or change your mode to OverwriteChanges.</em></h3>
  
  <p>I've tried just changing "CompareAllValues" to "OverwriteChanges" to postpone concurrency work for later, but that "breaks" Update and Delete commands, which just seem to refresh the ListView with the old values. The only threads I could find that resolved this issue involved changing to "OverwriteChanges" or were people who didn't have a "DataKeyNames" declared. Relevent markup is below (I hope).</p>
  
  <p>Any thoughts?</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="ManageUsersSource" runat="server" 
      ConflictDetection="CompareAllValues" 
      ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" 
          DeleteCommand="DELETE FROM [DUSER] WHERE [userid] = ? AND (([username] = ?) OR ([username] IS NULL AND ? IS NULL)) AND (([userpass] = ?) OR ([userpass] IS NULL AND ? IS NULL))" 
      InsertCommand="INSERT INTO [DUSER] ([username], [userpass]) VALUES (?, ?)" 
      OldValuesParameterFormatString="original_{0}" 
      ProviderName="&lt;%$ ConnectionStrings:ConnectionString.ProviderName %&gt;" 
      SelectCommand="SELECT * FROM [DUSER] ORDER BY [userid] ASC" 
      UpdateCommand="UPDATE [DUSER] SET [username] = ?, [userpass] = ? WHERE [userid] = ? AND (([username] = ?) OR ([username] IS NULL AND ? IS NULL)) AND (([userpass] = ?) OR ([userpass] IS NULL AND ? IS NULL))"&gt;
      &lt;DeleteParameters&gt;
          &lt;asp:Parameter Name="original_userid" Type="Int16" /&gt;
          &lt;asp:Parameter Name="original_username" Type="String" /&gt;
          &lt;asp:Parameter Name="original_username" Type="String" /&gt;
          &lt;asp:Parameter Name="original_userpass" Type="String" /&gt;
          &lt;asp:Parameter Name="original_userpass" Type="String" /&gt;
      &lt;/DeleteParameters&gt;
      &lt;InsertParameters&gt;
      &lt;%--This is removed since [userid] is an automatically generated index.--%&gt;
          &lt;%--&lt;asp:Parameter Name="userid" Type="Int16" /&gt;--%&gt;
          &lt;asp:Parameter Name="username" Type="String" /&gt;
          &lt;asp:Parameter Name="userpass" Type="String" /&gt;
      &lt;/InsertParameters&gt;
      &lt;UpdateParameters&gt;
          &lt;asp:Parameter Name="username" Type="String" /&gt;
          &lt;asp:Parameter Name="userpass" Type="String" /&gt;
          &lt;asp:Parameter Name="original_userid" Type="Int16" /&gt;
          &lt;asp:Parameter Name="original_username" Type="String" /&gt;
          &lt;asp:Parameter Name="original_username" Type="String" /&gt;
          &lt;asp:Parameter Name="original_userpass" Type="String" /&gt;
          &lt;asp:Parameter Name="original_userpass" Type="String" /&gt;
      &lt;/UpdateParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  &lt;asp:ListView ID="ListView1" runat="server" DataKeyNames="userid" 
      DataSourceID="ManageUsersSource" InsertItemPosition="LastItem"&gt;
      &lt;AlternatingItemTemplate&gt;
          &lt;tr style="background-color:#FFF8DC;"&gt;
              &lt;td&gt;
                  &lt;asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                      Text="Delete" /&gt;
                  &lt;asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="useridLabel" runat="server" Text='&lt;%# Eval("userid") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="usernameLabel" runat="server" Text='&lt;%# Eval("username") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="userpassLabel" runat="server" Text='&lt;%# Eval("userpass") %&gt;' /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/AlternatingItemTemplate&gt;
      &lt;EditItemTemplate&gt;
          &lt;tr style="background-color:#008A8C;color: #FFFFFF;"&gt;
              &lt;td&gt;
                  &lt;asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                      Text="Update" /&gt;
                  &lt;asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                      Text="Cancel" /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="useridLabel1" runat="server" Text='&lt;%# Eval("userid") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="usernameTextBox" runat="server" 
                      Text='&lt;%# Bind("username") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="userpassTextBox" runat="server" 
                      Text='&lt;%# Bind("userpass") %&gt;' /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/EditItemTemplate&gt;
      &lt;EmptyDataTemplate&gt;
          &lt;table runat="server" 
              style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;"&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      No data was returned.&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/EmptyDataTemplate&gt;
      &lt;InsertItemTemplate&gt;
          &lt;tr style=""&gt;
              &lt;td&gt;
                  &lt;asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                      Text="Insert" /&gt;
                  &lt;asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                      Text="Clear" /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &amp;nbsp;&lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="usernameTextBox" runat="server" 
                      Text='&lt;%# Bind("username") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="userpassTextBox" runat="server" 
                      Text='&lt;%# Bind("userpass") %&gt;' /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/InsertItemTemplate&gt;
      &lt;ItemTemplate&gt;
          &lt;tr style="background-color:#DCDCDC;color: #000000;"&gt;
              &lt;td&gt;
                  &lt;asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                      Text="Delete" /&gt;
                  &lt;asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="useridLabel" runat="server" Text='&lt;%# Eval("userid") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="usernameLabel" runat="server" Text='&lt;%# Eval("username") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="userpassLabel" runat="server" Text='&lt;%# Eval("userpass") %&gt;' /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/ItemTemplate&gt;
      &lt;LayoutTemplate&gt;
          &lt;table runat="server"&gt;
              &lt;tr runat="server"&gt;
                  &lt;td runat="server"&gt;
                      &lt;table ID="itemPlaceholderContainer" runat="server" border="1" 
                          style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;
                          &lt;tr runat="server" style="background-color:#DCDCDC;color: #000000;"&gt;
                              &lt;th runat="server"&gt;
                              &lt;/th&gt;
                              &lt;th runat="server"&gt;
                                  userid&lt;/th&gt;
                              &lt;th runat="server"&gt;
                                  username&lt;/th&gt;
                              &lt;th runat="server"&gt;
                                  userpass&lt;/th&gt;
                          &lt;/tr&gt;
                          &lt;tr ID="itemPlaceholder" runat="server"&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr runat="server"&gt;
                  &lt;td runat="server" 
                      style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;"&gt;
                      &lt;asp:DataPager ID="DataPager1" runat="server"&gt;
                          &lt;Fields&gt;
                              &lt;asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                  ShowLastPageButton="True" /&gt;
                          &lt;/Fields&gt;
                      &lt;/asp:DataPager&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/LayoutTemplate&gt;
      &lt;SelectedItemTemplate&gt;
          &lt;tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;"&gt;
              &lt;td&gt;
                  &lt;asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                      Text="Delete" /&gt;
                  &lt;asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="useridLabel" runat="server" Text='&lt;%# Eval("userid") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="usernameLabel" runat="server" Text='&lt;%# Eval("username") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="userpassLabel" runat="server" Text='&lt;%# Eval("userpass") %&gt;' /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/SelectedItemTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>
  
  <p></p>