ASP. NET 2.0 Illustrated
Authors: Homer A. Sussman D.
Published year: 2006
Pages: 31-32/147
Buy this book on amazon.com >>


Summary

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.



5. Advanced Data and Page Techniques

In Chapters 3 and 4, you saw how the data source controls provide an interface between the display controls, such as the GridView and DetailsView , and the underlying data store, whether that is direct SQL statements to a database or via a data or business layer. There are many times when the existing functionality meets requirements, but there are also times when you need more control over the process.

One of those times is when you need access to the parameters of commands, both before and after the command is executed. Another is when you need to trigger actions when the data has been modified, so that other controls can update their contents. Others times where you might need more control are concurrency errors, such as what happens if more than one person updates the same data at the same time. You might want to ensure that when saving a record, the user is notified if someone else has also changed that record.

SQLServer 2005 is not only an improved version of SQL Server 2000, but offers a really exciting new feature: .NET is built into the database. This means that a variety of things that were written in T-SQL, such as stored procedures and functions, can now be done with managed languages such as VB.NET or C#. We're not going to examine those directly, but one topic worth covering is the creation and use of user-defined types; these allow you to extend the existing type system so that custom types in your application code can be stored directly in the database.

When dealing with data, especially data fetched from remote locations, performance is always an issue. For example, consider the case where data is fetched from a Web Service, which either responds slowly, or perhaps doesn't respond at all. You not only slow the performance of an individual page while it waits for its data, but you also affect the scalability of the Web site. Asynchronous techniques allow you to solve the scalability issue. So in this chapter we are going to cover the following:

  • The events of the data source controls

  • The events of the data display and edit controls

  • How to use pessimistic locking and handle concurrency errors

  • How to use asynchronous Web pages to improve scalability

  • How to create and use custom types in SQL Server 2005

All of these are great techniques that will help you interact with data you need to display and get the best out of your Web site.


ASP. NET 2.0 Illustrated
Authors: Homer A. Sussman D.
Published year: 2006
Pages: 31-32/147
Buy this book on amazon.com >>