title: How to reset value of ASP.NET ObjectdataSource parameter
body: <p>I have a gridview that is bound to an objectdatasource. There is paging and it works fine. Now there is also a searchbox on the page, and if someone clicks on the search button I want to reset the startRow parameter to 0, but it doesn't work: the current page is passed to the Select method of the datasource.</p>
  
  <pre><code>       &lt;asp:GridView runat="server" ID="gvCars" 
          AutoGenerateColumns="false" 
          DataKeyNames="Id"            
          AllowPaging="true" AllowSorting="true"
          PageSize="2" DataSourceID="dataSource"           
          OnDataBound="GridView_DataBound" OnRowCommand="gvCars_RowCommand" OnRowDataBound="gvCars_RowDataBound"&gt;               
  
         &lt;Columns&gt;
          ... 
         &lt;/Columns&gt;             
  
      &lt;/asp:GridView&gt;
      &lt;asp:ObjectDataSource ID="dataSource" EnablePaging="true" runat="server" 
          SelectCountMethod="GetCount" 
          MaximumRowsParameterName="PageSize" 
          StartRowIndexParameterName="StartRow" SortParameterName="SortExpression"
          SelectMethod="Get" 
          TypeName="DataSource"&gt;
  
          &lt;SelectParameters&gt;
              &lt;asp:Parameter Name="startRow" /&gt;  
              &lt;asp:Parameter Name="pageSize" /&gt;
              &lt;asp:Parameter Name="sortExpression" /&gt;                  
              &lt;asp:ControlParameter Name="searchTerm" ControlID="txtSearchTerm" PropertyName="Text" /&gt;
          &lt;/SelectParameters&gt;
      &lt;/asp:ObjectDataSource&gt;
  </code></pre>
  
  <p>and in the codebehind I try to do:</p>
  
  <pre><code>protected void btnSearch_Click(object sender, EventArgs e)
      {
          dataSource.SelectParameters["startRow"].DefaultValue = "0";
          gvCars.DataBind();
      }
  </code></pre>
  
  <p>but the get method of the objectdatasource is called with whatever page user was at the moment that he clicked the searchbutton.</p>