Reputation: 11307
My application is separated into three layers (presentation, business, and data access). Most of the pages in my application work like this:
[Presentation Layer]
public override void FillData()
{
grid.DataSource = AnimalBll.FindAnimal(
SessionHelper.GetLoginInfo(base.sessionId).First().Id);
grid.DataBind();
}
[Business Layer]
public static DataTable FindAnimal(int id)
{
var result = DBHelper.GetDataTableFromSP("FindAnimal", id);
return result;
}
As you can see I bind directly to the grid. So, why would I use an ObjectDataSource?
Upvotes: 3
Views: 1368
Reputation: 83356
The benefit of using an ODS is that it allows you to also update and save your entities automatically. With how you have it now, you'd have to catch the appropriate event (row_saving?) and then strip out the new values, and pass them to your ORM for saving.
Andrew is right though, ObjectDataSource almost never works well, you should avoid it at all costs.
For basic grid-type updating I've had decent luck with either a LinqDataSource or an EntityDataSource (assuming you're using L2S or EF), but again, for large applications you're going to want to stay away from things like this (separation of concerns and all that)
Upvotes: 3
Reputation: 351516
You shouldn't - they should never be used in a serious application. The ObjectDataSource
control discourages the separation of concerns in your application. Since you have already properly partitioned the different tiers of your app, an ObjectDataSource
would only cause problems and cross-tier responsibilities.
Upvotes: 5