title: Refactoring, changing DataSource types based on selectedIndexChanged event, C#
body: <p>I am dealing with a web application.  What is asked of me is that when the page loads, that my drop down list displays index 0, with specific properties to display and store.</p>
  
  <p>Based on that, there is a second down list to hold a list.</p>
  
  <p>Next on the <code>selectedIndexChanged</code> event, should my index in ddl1 (I'll call it), the data in ddl2 should change.</p>
  
  <p>The data being populated is all from a database query.</p>
  
  <p>I'm in the process of refactoring, and i am trying to find a way so that I can just pass some data to a <code>bindControls</code> method.  I'm having passing a general data type that could be cast based on a boolean value I am also passing to the method.</p>
  
  <p>Here's an example</p>
  
  <pre><code>IQueryable&lt;BankAccount&gt; accountQuery = db.BankAccounts.Where(x =&gt; x.ClientId 
  == clientId &amp;&amp; x.AccountNumber != accountNumber);
  
  
  private void bindControls(DropDownList ddl, string textFieldProp, string 
  dataFieldProp, boolean isBillPayment, object dataSource)
  {
      //this is where my confusion is... i don't know how to change the type
      //of the object
      if(isBillPayment == true)
         dataSource = typeof(IQueryable&lt;BankAccount&gt;);
       ddlDataSource = dataSource.ToList()
       ddlDataTextField = textFieldProp;
       ddlDataValueField = dataFieldProp;
       ddl.DataBind();
  }
  </code></pre>
  
  <p>I know there HAS to be a way that I can assign this data source to what I want. 
  the query i posted is just an example of what that data source is going to , i have three different possible table queries from either BankAccounts, TransactionTypes, or Payees.</p>
  
  <p>sorry i should have mentioned that, im sorry to for any confusion with it.  Maybe that makes more sense now</p>