tailieunhanh - ASP.NET 4 Unleased - p 43
Using the SqlDataSource Control LISTING .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 @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD html xmlns http 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 retrieves all movies that have titles that match the string entered into the TextBox control see Figure . FIGURE Show matching movies. 9 LISTING @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD html xmlns http 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 .
đang nạp các trang xem trước