What is the point of using .NET data sources?
-
What is the point of using data sources such as SqlDataSource or ObjectDataSource?
Consider a simple example of a web page with a dropdown list used to filter the content of a pageable, sortable GridView. Each control needs a data source and that results in two calls to SQL Server. We are also told to keep the number of "round trips" to SQL Server to a minimum, for best performance. These scenarios are incompatible (although the difference in my example is trivial).
The only solution I have spotted is to make a single call to a compound SQL Server stored procedure and to put the results in a dataset (a repeater cannot be used for a pageable, sortable GridView) and bind each control to the appropriate table in the dataset. The disadvantage to this method is that I now have to code the GridView Sorting and PageIndexChanging events rather than just supplying attributes for that control.
Dave
-
What is the point of using data sources such as SqlDataSource or ObjectDataSource?
Consider a simple example of a web page with a dropdown list used to filter the content of a pageable, sortable GridView. Each control needs a data source and that results in two calls to SQL Server. We are also told to keep the number of "round trips" to SQL Server to a minimum, for best performance. These scenarios are incompatible (although the difference in my example is trivial).
The only solution I have spotted is to make a single call to a compound SQL Server stored procedure and to put the results in a dataset (a repeater cannot be used for a pageable, sortable GridView) and bind each control to the appropriate table in the dataset. The disadvantage to this method is that I now have to code the GridView Sorting and PageIndexChanging events rather than just supplying attributes for that control.
Dave
The objectDataSource is a very tool. It allows you to bind collection of objects to a gridview instead of always using a dataset or a datatable, dataview. I wrote and article on the objectdatasource and the gridview. Take a look at it and let me know what you think? http://www.codeproject.com/useritems/GridViewObjectDataSource.asp[^] I am currently using something close to what I showed in this article in production now. The objects and the gridview it self are a lot more complex, but the basic function is the same. Ben