TAILIEUCHUNG - ASP.NET 4 Unleased - p 81

Trong Ví dụ 18,2, điều khiển ObjectDataSource có hai thuộc tính có tên là TypeName và SelectMethod. Các tài sản TypeName chứa tên của các thành phần mà bạn muốn thể hiện với các điều khiển ObjectDataSource. Các tài sản SelectMethod đại diện cho phương pháp của các thành phần mà bạn muốn gọi khi lựa chọn dữ liệu. Việc kiểm soát GridView là ràng buộc để kiểm soát ObjectDataSource thông qua sở hữu DataSourceID của nó. . | 774 CHAPTER 18 Using the ObjectDataSource Control In Listing the ObjectDataSource control includes two properties named TypeName and SelectMethod. The TypeName property contains the name of the component that you want to represent with the ObjectDataSource control. The SelectMethod property represents the method of the component that you want to call when selecting data. The GridView control is bound to the ObjectDataSource control through its DataSourcelD property. When you open the page in Listing the list of movies is retrieved from the MovieCollection component and displayed in the GridView. The MovieCollection component contains instance methods. The ObjectDataSource automatically creates a new instance of the MovieCollection component before calling its GetMovies method. It automatically destroys the object after it finishes using the object. You also can use the ObjectDataSource control to call shared static methods. In that case the ObjectDataSource doesn t need to instantiate a component before calling the method. Binding to a DataReader Typically you use the ObjectDataSource control to represent database data. The .NET Framework provides you with multiple ways of representing data. This section discusses how you can use an ObjectDataSource to represent a DataReader. NOTE The different objects are compared and contrasted in Chapter 19 Building Data Access Components with . The DataReader object provides you with a fast read-only representation of database data. If you need to retrieve database records in the fastest possible way you should use a DataReader object. For example the component in Listing the MovieDataReader component returns all the movies from the Movies database table by using the SqlDataReader object. The component imports the namespace to use this Microsoft SQL Server-specific object. LISTING using System using using .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.