title: Delete command not firing on post back, asp.net repeater
body: <p>I have a page that contains a data repeater which in turn contains a button that is meant to delete a delete a record from an SQL database. When this button is clicked I receive the following error: Procedure or function 'usp_setKS3_DeleteAssessment' expects parameter '@intAssessmentId', which was not supplied.</p>
  
  <p>If I comment out the KS3_DataSource_Assessment.Delete(); line in the code behind the page loads without error and displays the message, but does not delete the record (which I expect as the line was commented out). I have no idea what to do to make this work... any ideas?</p>
  
  <p>ASP.net</p>
  
  <pre><code>    &lt;asp:SqlDataSource ID="KS3_DataSource_Assessment" runat="server" ConnectionString="&lt;%$ ConnectionStrings:sqlWriter %&gt;" ProviderName="System.Data.SqlClient" SelectCommandType="StoredProcedure" SelectCommand="usp_getKS3_ManageAssessments" OnSelected="KS3_DataSource_Assessment_Selected" DeleteCommand="usp_setKS3_DeleteAssessment"&gt;
                                      &lt;SelectParameters&gt;
                                          &lt;asp:ControlParameter ControlID="KS3_DropDown_ACYear" PropertyName="SelectedValue" Name="intACYearId" Type="Int32" /&gt;
                                          &lt;asp:ControlParameter ControlID="KS3_DropDown_Subject" PropertyName="SelectedValue" Name="intSubjectId" Type="Int32" /&gt;
                                          &lt;asp:ControlParameter ControlID="KS3_DropDown_Year" PropertyName="SelectedValue" Name="intYearGroup" Type="Int32" /&gt;
                                      &lt;/SelectParameters&gt;
                                      &lt;DeleteParameters&gt;
                                          &lt;asp:Parameter Name="intAssessmentId" Type="Int32" /&gt;
                                      &lt;/DeleteParameters&gt;
                                  &lt;/asp:SqlDataSource&gt;
                                  &lt;asp:Repeater runat="server" ID="KS3_Repeater_Assessments" EnableViewState="true" DataSourceID="KS3_DataSource_Assessment" OnItemDataBound="KS3_Repeater_Assessments_ItemDataBound"&gt;
                                      &lt;ItemTemplate&gt;
                                          &lt;!-- Assessments --&gt;
                                          &lt;asp:Table runat="server" ID="KS3_Table_Assessments" CssClass="width100pc"&gt;
                                              &lt;asp:TableRow CssClass="SectionSubHeader"&gt;
                                                  &lt;asp:TableCell&gt;&lt;%# Eval("txtAssessmentTitle").ToString() %&gt;&lt;/asp:TableCell&gt;
                                                  &lt;asp:TableCell CssClass="width25px alignCenter alignVerticalMiddle" RowSpan="2"&gt;&lt;asp:ImageButton SkinID="imgButtonDelete" runat="server" ID="KS3_Button_DeleteAssessment" OnCommand="KS3_Button_DeleteAssessment_Command" CommandArgument='&lt;%# Eval("intAssessmentID").ToString() %&gt;' OnClientClick="return confirm('Are you sure you want to delete this assessment?\n\nOnce deleted all data is lost.');" /&gt;&lt;/asp:TableCell&gt;
                                                  &lt;asp:TableCell CssClass="width25px alignCenter alignVerticalMiddle" RowSpan="2"&gt;Up&lt;/asp:TableCell&gt;
                                                  &lt;asp:TableCell CssClass="width25px alignCenter alignVerticalMiddle" RowSpan="2"&gt;Down&lt;/asp:TableCell&gt;
                                              &lt;/asp:TableRow&gt;
                                              &lt;asp:TableRow CssClass="BackgroundBlack fontStyleItalic"&gt;
                                                  &lt;asp:TableCell&gt;&lt;%# Eval("txtAssessmentDescription").ToString() %&gt;&lt;/asp:TableCell&gt;
                                              &lt;/asp:TableRow&gt;
                                          &lt;/asp:Table&gt;
  
                                          &lt;!-- Columns --&gt;
                                          &lt;asp:SqlDataSource ID="KS3_DataSource_Columns" runat="server" ConnectionString="&lt;%$ ConnectionStrings:sqlWriter %&gt;" ProviderName="System.Data.SqlClient" SelectCommandType="StoredProcedure" SelectCommand="usp_getKS3_ManageAssessments"&gt;
                                              &lt;SelectParameters&gt;
                                                  &lt;asp:Parameter Name="intACYearId" Type="Int32" /&gt;
                                              &lt;/SelectParameters&gt;
                                          &lt;/asp:SqlDataSource&gt;
  
                                      &lt;/ItemTemplate&gt;
                                  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>Code Behind</p>
  
  <pre><code>        protected void Page_Load(object sender, EventArgs e)
  {
  
  }
  
  protected void KS3_Button_SelectSubject_Click(object sender, EventArgs e)
  {
      if (KS3_DropDown_Subject.SelectedIndex == 0) { DisplayMessage("Validation Error", "Please select a subject from the list below.", "error"); KS3_Panel_DataToManage.Visible = false; }
      else if (KS3_DropDown_Year.SelectedIndex == 0) { DisplayMessage("Validation Error", "Please select a year group from the list below.", "error"); KS3_Panel_DataToManage.Visible = false; }
      else
      {
          //No errors detected, start data display
          Master.systemMessageHide();
          KS3_Panel_DataToManage.Visible = true;
  
          //Update display
          KS3_Label_Title.Text = KS3_DropDown_Subject.SelectedItem.Text.Trim() + " - " + KS3_DropDown_Year.SelectedItem.Text.Trim();
  
          //Bind the new data to the repeater
          KS3_Repeater_Assessments.DataBind();
      }
  }
  
  public void DisplayMessage(string title, string message, string type)
  {
      Master.systemMessageShow(title, message, type);
  }
  
  protected void KS3_DataSource_Assessment_Selected(object sender, SqlDataSourceStatusEventArgs e)
  {
      if (e.AffectedRows &lt; 1) { KS3_Panel_NoAssessments.Visible = true; }
      else { KS3_Panel_NoAssessments.Visible = false; }
  }
  
  
  protected void KS3_Button_DeleteAssessment_Command(object sender, CommandEventArgs e)
  {
      KS3_Label_Title.Text = "DataSubmitted";
      KS3_DataSource_Assessment.DeleteParameters["intAssessmentId"].DefaultValue = e.CommandArgument.ToString();
      Trace.Write("Item Value: " + e.CommandArgument.ToString());
      KS3_DataSource_Assessment.Delete();
      KS3_Repeater_Assessments.DataBind();
      DisplayMessage("Assessment Delete", "The selected assessment has been deleted and all associated data has been removed.", "success");
  } 
  </code></pre>