title: How to convert a DataTable/DataSet into a ObjectDataSource
body: <p>I have a GridView that's tied to an ObjectDataSource. I have a method that returns a DataTable. How do I feed the DataTable to the ObjectDataSource so that the GridView is updated in code?</p>
  
  <p>Example:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e) 
  {
      MyClass obj = new MyClass(textbox.Text);
      DataTable dt = obj.GetData();
  
      ObjectDataSource1.DataSource = dt; 
  }
  </code></pre>
  
  <p>Yes, I know that the ODS does not have DataSource property. That's why I'm stuck.</p>
  
  <p>If you're thinking, why not just assign the GridView the DataTable directly; the answer is: We like the auto-sorting capabilities offered by the ODS + GridView combo.</p>
  
  <p>All searches on Google have returned are how to get a DT from an ODS. I can't find a single reference on how to get a DT into the ODS. It would seem that this is quite a common need since people coming from ASP.NET 1.1 will have a lot of code that generates DT and if they want to update the UI, they will want to get the DT into the ODS.</p>