title: How to change the SelectMethod of ObjectDataSource programatically?
body: <p>Suppose I have a given ObjectDataSource, this objectdatasource "SelectMethod" property is set to "GetProjectsByUsername" of a class Project and accepting one parameter.</p>
  
  <pre><code> &lt;asp:ObjectDataSource ID="GetProjectsDataSource" runat="server" SelectMethod="GetProjectsByUsername"
      TypeName="BusinessLayer.Project"&gt;
      &lt;SelectParameters&gt;
          &lt;asp:ControlParameter ControlID="hiddenUsername" Name="username" PropertyName="Value"
              Type="String" /&gt;
      &lt;/SelectParameters&gt;
  &lt;/asp:ObjectDataSource&gt;
  </code></pre>
  
  <p>Now, Is it possible to change the SelectMethod property of this ObjectDataSource to a method that accepts two parameters during OnInit method? for example </p>
  
  <p>MethodName :  GetProjectByUsernameDeptCd()<br>
  Parameters : Username , DepartmentCode</p>
  
  <p>I would like to change the select method by User Roles. I've tried to search SO and Internet but it seems that I have no luck on it. Anyway I wanted to do like:</p>
  
  <blockquote>
    <p>if ( Role is Admin )<br>
           Use the default SelectMethod and Parameters that is declared in ASPX<br>
      else<br>
           Change the SelectMethod to "GetProjectByUsernameDeptCd"<br>
            Set parameter1 = value1<br>
           Set parameter2 = value2  </p>
  </blockquote>
  
  <p>Or I was thinking if there are other better ways to do this.</p>
  
  <p>Thank You and Best Regards,
  Sherwin</p>