- SqlDataSource - Can be used with SQL Server database as the back end, takes care of DIRT/CRUD operations using T-SQL embedded in its properties.
- XmlDataSource - Can be used with XML as the backend.
- LinqDataSource - A newcomer, can be used when displaying objects implementing the IQueryable interface
- AccessDataSource - As the name suggests, use it when you are using Access as a back end.
- ObjectDataSource - Can be used when the data is stored as custom objects or POCO (Plain old CLR object)
Since Microsoft .net framework 1.0, anyone who binds an object datasource with a datacontrol you would get an error when you try to sort from the data control
The data source 'GridSource' does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet
That meant this error has not been sorted out since .net 1.0. My reaction was, REEEAAAALLLY??WTF...now what will I do with my 100's of entity/DTO classes. Do I have to use Typed Datasets?? I am dealing with millions of rows in tables, is DataSets/ DataTables good, considering all the diffgram stuff etc??I stumbled upon a few blogs/articles -
http://devtoolshed.blogspot.com/2008/03/gridview-objectdatasource-linq-paging.html
http://borrell.parivedasolutions.com/2008/01/objectdatasource-linq-paging-sorting.html
And I am sure if you look hard enough you will find more. If you follow these articles you will be able to perform paging, sorting and selections. If you get more greedy and try to add deleteion, updation and insertion in the datacontrol...9/10 times you will see
ObjectDataSource 'RolesDataSource' could not find a non-generic method 'Update' that has parameters: RoleId, RoleName, Description, original_ApplicationId, original_LoweredRoleName.
Again I went WTF?? What do I need do now?? I went to Mr. Scott Guthrie's blog and he suggested to use DataKeyNames but guess what..it doesnt work. Other blogs have suggested different metods to solve this problem, most of them are mere hacks. Some examples arehttp://weblogs.asp.net/bradygaster/archive/2006/09/26/How-to-Bloody-Your-Forehead.aspx
most solutions are SQL centric and are useless if your data methods are like Add(Customer entity) or Remove(Customer entity). I am extremely tired of playing with DataControls and ObjectDatasource. I want to wait for new Gridview and new ObjectDatasource unless there is someone smart enough out there to give me a complete example that has a master/detail, CRUD, searching, filtering, sorting, paging without embedding SQL in the control and not using DataSets/DataTables. Comeon Microsoft; it shouldnt be so hard it is such a mundane task for programmers to implement these features. Is your answer Dynamic Data???
Cheers
X