Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Việc kiểm soát ObjectDataSource bao gồm một tài sản DataObjectTypeName. tài sản này có chứa tên của một đối tượng sử dụng với các UpdateEmployee () phương pháp. Khi UpdateEmployee () được gọi là, một thể hiện của các thành phần CompanyEmployee được tạo ra và được truyền cho phương pháp này. | 794 CHAPTER 18 Using the ObjectDataSource Control The ObjectDataSource control includes a DataObjectTypeName property. This property contains the name of an object used with the UpdateEmployee method. When the UpdateEmployee method is called an instance of the CompanyEmployee component is created and passed to the method. NOTE The DataObjectTypeName property has an effect on only the methods represented by the InsertMethod UpdateMethod and DeleteMethod properties. It does not have an effect on the method represented by the SelectMethod property. There is one important limitation when using the DataObjectTypeName property. The object represented by this property must have a parameterless constructor. For example you could not use the following CompanyEmployee class with the DataObjectTypeName property public class CompanyEmployee private string _firstName public string FirstName get return _firstName public void CompanyEmployee string firstName _firstName firstName The problem with this class is that it initializes its FirstName property in its constructor. Its constructor requires a firstName parameter. Instead you need to use a class that looks like this public class CompanyEmployee private string _firstName From the Library of Wow eBook Paging Sorting and Filtering Data with the ObjectDataSource Control 795 public string FirstName get return _firstName set _firstName value This class has a parameterless constructor. The FirstName property is a read write property. If you have the need you can get around this limitation by handling the Inserting Updating or Deleting event. When you handle one of these events you can pass any object that you need to a method. These events are discussed later in this chapter in the section Handling ObjectDataSource Events. Paging Sorting and Filtering Data with the ObjectDataSource Control The ObjectDataSource control provides you with two options for paging and sorting database data. You can take advantage of either user interface