tailieunhanh - ASP.NET 4 Unleased - p 70
Chú ý Trong ASP NET ., LayoutTemplate được yêu cầu và nó cần thiết để có một điều khiển serverside với một ID của itemContainer. Trong ASP NET 4., LayoutTemplate không còn cần thiết. | 664 CHAPTER 14 Using the ListView and DataPager Controls NOTE In ASPNET the LayoutTemplate was required and it needed to contain a serverside control with an ID of itemContainer. In ASPNET 4 LayoutTemplate is no longer required. FIGURE Displaying database records with a ListView control. The ItemTemplate renders each of the items from the data source or every other item when an AlternatingItemTemplate is present . In Listing the ItemTemplate renders a div tag with a solid border. A data-binding expression is used with the div tag to display the value of the database Title column. The AlternatingItemTemplate is optional. If it is present every other item displayed by the ListView control is rendered with the AlternatingItemTemplate. In Listing the AlternatingItemTemplate is used to give alternating items a silver background color. Finally the EmptyDataTemplate displays content when no results are retrieved from the data source. In Listing the EmptyDataTemplate is used to display the text No Records Found when no items are returned from the data source. You can use the ListView control to render any HTML elements you can imagine. You can use the ListView control to render bulleted lists an HTML table a blog tag cloud or even the elements of a JavaScript array. For example the page in Listing uses a ListView control to render an HTML table. LISTING @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML Transitional EN http TR xhtml1 DTD html xmlns http 1999 xhtml head id Head1 runat server From the Library of Wow eBook Using the ListView Control 665 title Table ListView title head body form id form1 runat server div asp ListView ID lstMovies DataSourceId srcMovies runat server LayoutTemplate table thead tr th Title th th Director th tr thead tbody asp Placeholder id itemPlaceholder runat server tbody table LayoutTemplate ItemTemplate tr td Eval Title td td Eval .
đang nạp các trang xem trước