Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 43
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Using the SqlDataSource Control LISTING 9.9 ShowMovieCount.aspx .gridView { margin:0px auto; border:solid 4px black; background-color:white; } .gridView td, .gridView th { padding:20px; } html { background-color:silver; font-family:Georgia, Serif; } Show Movie Count ” Runat=”server” / From the Library of Wow! eBook Executing Database | 394 CHAPTER 9 Using the SqlDataSource Control LISTING 9.9 ShowMovieCount.aspx @ Page Language C 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 style type text css .gridView margin 0px auto border solid 4px black background-color white .gridView td .gridView th padding 20px html background-color silver font-family Georgia Serif style title Show Movie Count title head body form id form1 runat server div asp GridView id grdMovies DataSourceID srcMovies CssClass gridView Runat server asp SqlDataSource id srcMovies SelectCommand CountMoviesInCategory SelectCommandType StoredProcedure ConnectionString ConnectionStrings Movies Runat server From the Library of Wow eBook Executing Database Commands 395 div form body html Filtering Database Rows The SqlDataSource control includes a FilterExpression property that enables you to filter the rows returned by the control. You can define complex Boolean filters that include parameters with this property. For example the page in Listing 9.10 retrieves all movies that have titles that match the string entered into the TextBox control see Figure 9.6 . FIGURE 9.6 Show matching movies. 9 LISTING 9.10 ShowFilterExpression.aspx @ Page Language C 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 style type text css From the Library of Wow eBook 396 CHAPTER 9 Using the SqlDataSource Control td th padding 10px style title Show Filter Expression title head body form id form1 runat server div asp TextBox id txtTitle Runat server asp Button id btnMatch Text Match Runat server hr asp GridView id grdMovies DataSourceId srcMovies Runat server asp SqlDataSource id srcMovies SelectCommand SELECT Id Title Director DateReleased FROM Movies FilterExpression Title LIKE 0 ConnectionString ConnectionStrings Movies Runat server FilterParameters asp .