I have a GridView attached to an ObjectDataSource. I have a method that returns a DataTable. How can I pass a DataTable to an ObjectDataSource so that the GridView is updated in code?
Example:
protected void Page_Load(object sender, EventArgs e)
{
MyClass obj = new MyClass(textbox.Text);
DataTable dt = obj.GetData();
ObjectDataSource1.DataSource = dt;
}
Yes, I know that ODS does not have the DataSource property. That is why I am stuck.
If you are thinking, why not just assign a GridView DataTable directly; the answer is: we like the automatic sorting capabilities offered by the ODS + GridView combine.
All google searches are back, how to get DT from ODS. I can not find any links on how to get DT in ODS. This would seem to be a fairly common need, since people coming from ASP.NET 1.1 will have a lot of code that DT generates, and if they want to update the user interface, they will want to get DT in ODS.
source
share