Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Using the SqlDataSource Control ” Runat=”server” The SqlDataSource control in Listing 9.24 includes a QueryStringParameter. The QueryStringParameter supplies the movie ID in the SqlDataSource control’s SelectCommand. Using the SessionParameter Object The SessionParameter object enables you to represent any item stored in Session state. The SessionParameter object includes all the properties of the base Parameter class and the following property: . SessionField—The | 424 CHAPTER 9 Using the SqlDataSource Control asp DetailsView id dtlMovie DataSourceID srcMovie Runat server asp HyperLink Runat server Text Back. NavigateUrl ShowQueryStringParameterMaster.aspx asp SqlDataSource id srcMovie SelectCommand SELECT FROM Movies WHERE Id @Id ConnectionString ConnectionStrings Movies Runat server SelectParameters asp QueryStringParameter Name Id QueryStringField Id SelectParameters asp SqlDataSource div form body html The SqlDataSource control in Listing 9.24 includes a QueryStringParameter. The QueryStringParameter supplies the movie ID in the SqlDataSource control s SelectCommand. Using the SessionParameter Object The SessionParameter object enables you to represent any item stored in Session state. The SessionParameter object includes all the properties of the base Parameter class and the following property SessionField The name of the item stored in Session state that the SessionParameter represents. NOTE Session state is discussed in detail in Chapter 28. From the Library of Wow eBook Using ASf.NET Parameters with the SqlDataSource Control 425 The page in Listing 9.25 contains a GridView that displays a list of movies matching a movie category. The movie category is stored in Session state. LISTING 9.25 ShowSessionParameter.aspx @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML 1.1 EN http www.w3.org TR xhtml11 DTD xhtml11.dtd script runat server void Page_Load Session MovieCategoryName Animation script html xmlns http www.w3.org 1999 xhtml head id Head1 runat server title Show SessionParameter title head body form id form1 runat server div asp GridView id grdMovies DataSourceID srcMovies Runat server asp SqlDataSource id srcMovies SelectCommand SELECT Name As Category Title Director FROM Movies INNER JOIN MovieCategories ON CategoryId MovieCategories.id WHERE Name @Name ConnectionString ConnectionStrings Movies Runat server SelectParameters asp SessionParameter Name Name SessionField MovieCategoryName SelectParameters asp .