Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 87

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Using the ObjectDataSource Control FIGURE 18.11 Using the MovieDataSource control to display movies. LISTING 18.41 ShowMovieDataSource.aspx Show Movie DataSource From the Library of Wow! eBook Extending the ObjectDataSource Control 835 The custom control must be registered with a directive at the top of Listing 18.41. After you register the control, you can simply declare the MovieDataSource | 834 CHAPTER 18 Using the ObjectDataSource Control FIGURE 18.11 Using the MovieDataSource control to display movies. LISTING 18.41 ShowMovieDataSource.aspx @ Page Language C @ Register TagPrefix custom Namespace AspNetUnleashed.Samples DOCTYPE html PUBLIC - W3C DTD XHTML 1.1 EN http www.w3.org TR xhtml11 DTD xhtml11.dtd html xmlns http www.w3.org 1999 xhtml head id Head1 runat server title Show Movie DataSource title head body form id form1 runat server div asp GridView id grdMovies DataSourceID srcMovies Runat server custom MovieDataSource id srcMovies Runat server From the Library of Wow eBook Extending the ObjectDataSource Control 835 div form body html The custom control must be registered with a @ Register directive at the top of Listing 18.41. After you register the control you can simply declare the MovieDataSource control in the page to represent the contents of the Movies database table. NOTE As an alternative to registering the MovieDataSource control in a page you can register the control for an entire application in the web configuration file within the pages element. Creating Custom Parameter Objects The standard DataSource Parameter objects included in the ASP.NET Framework enable you to represent objects such as query string values items from Session state and the values of control properties. If none of the standard Parameter objects satisfy your requirements you always have the option of creating a custom Parameter object. You create a custom Parameter object by deriving a new class from the base Parameter class. In this section we create two custom parameters. The first is a UsernameParameter that automatically represents the current username. Next is a PagePropertyParameter that represents the current value of a property contained in the page. Creating a Username Parameter The UsernameParameter class is contained in Listing 18.42. The class in Listing 18.42 derives from the Parameter class and overrides the Evaluate method of the base class. The .

TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã 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.