In this chapter, we have looked at two ways of creating data and business layers: custom classes and typed DataSets. Both are created in the App_Code directory, means that they automatically get compiled by ASP.NET, so there is no need to create class libraries and deploy them to the application bin directory. For a custom class, you simply create methods to return data and methods to accept data to be modified. While the example in the chapter showed only the basic methods, there is no limit to the number and type you can createit simply depends upon the requirement of your business object. For typed DataSets, the basic operations are automatically created for you, and if you require additional methods, you need to create a partial class with the added functionality. You will also need to modify the existing commands to ensure that IDENTITY fields aren't modified in the UpdateCommand and InsertCommand. Whatever type of object you use, the ObjectDataSource provides the interface between the object and databound controls. In the next chapter, we'll look at this interface in more detail, seeing how you can use the events of the data source controls to run code before and after command execution, and we'll also see how data can be cached to improve performance. |