title: SqlDataSource UpdateCommand parameters not changing
body: <p>I have a <code>FormView</code> with an <code>UpdateButton</code> and a <code>SqlDataSource</code> which are below. My <code>updatebutton</code> always update the <code>Sil</code> table with the same values (the values at the first line of my gridview), I couldn't figure out why. </p>
  
  <pre><code>&lt;asp:FormView ID="frm_Benefit" runat="server" DataKeyNames="ID" DataSourceID="sds_Benefits"
              OnItemInserted="frm_Benefit_ItemInserted" OnItemUpdated="frm_Benefit_ItemUpdated"&gt;
      &lt;EditItemTemplate&gt;
          &lt;table class="formview"&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Code:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="CodeTextBox" runat="server" Text='&lt;%# Bind("Code") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Name:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="NameTextBox" runat="server" Text='&lt;%# Bind("Name") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      HRName:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="HRNameTextBox" runat="server" Text='&lt;%# Bind("HRName") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Description:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="DescriptionTextBox" runat="server" Text='&lt;%# Bind("Description") %&gt;'
                          TextMode="MultiLine" MaxLength="200" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Associated Url:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="UrlTextBox" runat="server" Text='&lt;%# Bind("Url") %&gt;' MaxLength="100" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      BenefitType:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="sds_BenefitTypes"
                          DataTextField="Name" DataValueField="ID" SelectedValue='&lt;%# Bind("BenefitTypeID") %&gt;'&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Cost:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="CostTextBox" runat="server" Text='&lt;%# Bind("Cost") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Cost Type:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:DropDownList ID="CostTypeDropDown" runat="server" DataSourceID="sds_CostTypes"
                          DataTextField="Name" DataValueField="ID" SelectedValue='&lt;%# Bind("CostTypeID") %&gt;'&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Quantity Type:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:DropDownList ID="QuantityTypeDropDown" runat="server" DataSourceID="sds_QuantityTypes"
                          DataTextField="Name" DataValueField="ID" SelectedValue='&lt;%# Bind("QuantityTypeID") %&gt;'&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Quantity Entry On Add:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:CheckBox ID="QuantityEntryOnAddCheckBox" runat="server" Checked='&lt;%# Bind("QuantityEntryOnAdd") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Quantity Entry On Remove:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:CheckBox ID="QuantityEntryOnRemoveCheckBox" runat="server" Checked='&lt;%# Bind("QuantityEntryOnRemove") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Bonus Ratio:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="BonusRatioTextBox" runat="server" Text='&lt;%# Bind("BonusRatio") %&gt;'&gt;&lt;/asp:TextBox&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      ApplyIncomeTax:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:CheckBox ID="ApplyIncomeTaxCheckBox" runat="server" Checked='&lt;%# Bind("ApplyIncomeTax") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      ApplyStampTax:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:CheckBox ID="ApplyStampTaxCheckBox" runat="server" Checked='&lt;%# Bind("ApplyStampTax") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="style1"&gt;
                      ApplySocialSecurityTax:
                  &lt;/td&gt;
                  &lt;td class="style1"&gt;
                      &lt;asp:CheckBox ID="ApplySocialSecurityTaxCheckBox" runat="server" Checked='&lt;%# Bind("ApplySocialSecurityTax") %&gt;' /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Applicable Location:
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:DropDownList ID="CostTypeDropDown1" runat="server" DataSourceID="sds_Locations"
                          DataTextField="Name" DataValueField="ID" SelectedValue='&lt;%# Bind("ApplicableLocationID") %&gt;'&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;
                      &lt;asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                          Text="Update" Style="display: none" /&gt;
                      &amp;nbsp;&lt;asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
                          CommandName="Cancel" Text="Cancel" Style="display: none" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/EditItemTemplate&gt;
  &lt;/asp:FormView&gt;
  
  &lt;asp:SqlDataSource ID="sds_Benefits" runat="server"  ConnectionString="&lt;%$ ConnectionStrings:ConnFlexibleBenefitsDB %&gt;"
      SelectCommand="SELECT * FROM [View_Benefits]" 
      UpdateCommand="UPDATE [Sil] SET [Code] = @Code, [HRName] = @HRName WHERE [Id] = @Id"&gt;
      &lt;UpdateParameters&gt;
          &lt;asp:Parameter Name="Code" Type="String" /&gt;
          &lt;asp:Parameter Name="HRName" Type="String" /&gt;
          &lt;asp:Parameter Name="Id" Type="Int32" /&gt;
      &lt;/UpdateParameters&gt;
  
  &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>And this is my gridview:</p>
  
  <pre><code>&lt;asp:GridView ID="grd_Benefits" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
      CssClass="gridTable" DataSourceID="sds_Benefits" OnRowCommand="grd_Benefits_RowCommand"&gt;
      &lt;RowStyle CssClass="gridRow" /&gt;
      &lt;FooterStyle CssClass="gridFooter" /&gt;
      &lt;SelectedRowStyle CssClass="gridSelectedRow" /&gt;
      &lt;HeaderStyle CssClass="gridHeader" /&gt;
      &lt;AlternatingRowStyle CssClass="gridAlternatingRow" /&gt;
      &lt;EmptyDataTemplate&gt;
          No records found.
      &lt;/EmptyDataTemplate&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="Code" HeaderText="Code" SortExpression="Code" /&gt;
          &lt;asp:BoundField DataField="HRName" HeaderText="HRName" SortExpression="HRName" /&gt;
          &lt;asp:TemplateField HeaderText="Benefit Type" SortExpression="BenefitType.Name"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Bind("BenefitTypeName") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:BoundField DataField="Cost" HeaderText="Cost" SortExpression="Cost" /&gt;
          &lt;asp:TemplateField HeaderText="Cost Type"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label2" runat="server" Text='&lt;%# Bind("CostTypeName") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Quantity Type"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label3" runat="server" Text='&lt;%# Bind("QuantityTypeName") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="lbSelect" runat="server" CausesValidation="False" CommandName="ViewRecord"
                      Text="&amp;lt;img border='0' alt='Edit' src='../images/zoom.gif' /&amp;gt;" CommandArgument='&lt;%# Container.DataItemIndex %&gt;'&gt;&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField ShowHeader="False"&gt;
              &lt;HeaderTemplate&gt;
                  &lt;asp:LinkButton ID="lbInsert" runat="server" CausesValidation="false" CommandName="NewRecord"
                      Text="&amp;lt;img border='0' alt='New' src='../images/new.gif'  /&amp;gt;" CommandArgument='&lt;%# Container.DataItemIndex %&gt;'
                      ForeColor="White"&gt;&lt;/asp:LinkButton&gt;
              &lt;/HeaderTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="EditRecord"
                      Text="&amp;lt;img border='0' alt='Edit' src='../images/edit.gif' /&amp;gt;" CommandArgument='&lt;%# Container.DataItemIndex %&gt;'&gt;&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>RowCommand: </p>
  
  <pre><code>    protected void grd_Benefits_RowCommand(object sender, GridViewCommandEventArgs e)
      {            
          if (e.CommandName == "ViewRecord")
          {
              grd_Benefits.SelectedIndex = int.Parse(e.CommandArgument.ToString());
              frm_Benefit.ChangeMode(FormViewMode.ReadOnly);
              Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFormViewView", "&lt;script type=\"text/javascript\"&gt;showFormViewView();&lt;/script&gt;");
          }
          else if (e.CommandName == "NewRecord")
          {
              frm_Benefit.ChangeMode(FormViewMode.Insert);
              Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFormViewInsert", "&lt;script type=\"text/javascript\"&gt;showFormViewInsert();&lt;/script&gt;");
          }
          else if (e.CommandName == "EditRecord")
          {
              grd_Benefits.SelectedIndex = int.Parse(e.CommandArgument.ToString());
              frm_Benefit.ChangeMode(FormViewMode.Edit);
              Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFormViewEdit", "&lt;script type=\"text/javascript\"&gt;showFormViewEdit();&lt;/script&gt;");
          }
      }
  </code></pre>