Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
5,5 Hiển thị dữ liệu Sử dụng Repeater Control Tôi có nghe nói rằng việc kiểm soát Repeater là một điều khiển tuyệt vời cho hiển thị một danh sách chỉ đọc các giá trị, bao gồm các siêu liên kết. Làm thế nào để cư một điều khiển Repeater và tận dụng các mẫu để hiển thị các dữ liệu cách tôi muốn nó nhìn? | 5.5 Display Data Using the Repeater Control I have heard that the Repeater control is a great control for displaying a read-only list of values including hyperlinks. How do I populate a Repeater control and take advantage of templates to display the data the way I want it to look Technique The Repeater control allows you to list data in various formats such as bulleted or numbered. It relies on the use of templates to display information in a list format. This How-To shows you how to use the Repeater control not only to display a list but also to use a couple of different controls-a Button and HyperLink-to display another list using the Repeater control. The second list will be displayed using the button on the same page as the first list. The hyperlink will take you to another page to display the second list. A main tool in the creation of the Repeater control is the use of templates. Use of Templates Templates are used within HTML and allow you to include controls in your ASP.NET Web server controls. Within a template you can specify various details about the area for which you are creating a template. Following is a list of the templates HeaderTemplate ItemTemplate FooterTemplate AlternatingItemTemplate SeparatorTemplate You can get an idea of what each of the templates is used for by its name. Here is an example of the HeaderTemplate used in this How-To HeaderTemplate font face Arial Black size 2 List of Regions font br HeaderTemplate These lines are literally used as a template for how you want the section to be laid out as well as what data to display. For the ItemTemplate in this How-To two controls are displayed a button and a hyperlink shown by this snippet of the HTML asp Button runat server Text DataBinder.Eval Container.DataItem RegionlD asp HyperLink Runat server Text DataBinder.Eval Container Dataltem.RegionDescription NavigateURL DataBinder.Eval Container Dataltem.RegionURL ID HyperLink1 As the name implies the DataBinder supplies data from the data