title: Set a datalist.datasource from inside a usercontrol - asp.net c#
body: <p>I have a usercontrol that contains a datalist, and I want to set the datasource of the datalist to different things depending on what page the usercontrol is on. </p>
  
  <p>So, I think what I need to do is expose a public property of the datalist that will get the datasource and set it, like so:</p>
  
  <pre><code>public datasource UserDataSource
  {
  get { return DataList1.DataSource; }
  set { DataList1.DataSource = value; }
  }
  </code></pre>
  
  <p>but the above obviously doesn't work. I'd then call it like this:</p>
  
  <pre><code>MyUserControl.UserDataSource = datasourcename;
  </code></pre>
  
  <p>and then somehow databind the datalist inside the usercontrol. </p>
  
  <p>Obviously I'm kind of out of my element here, but hopefully I can get this working. Thanks for any help.</p>