Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Professional ASP.NET 3.5 in C# and Visual Basic Part 46. Building on the revolutionary ASP.NET 2.0 release, ASP.NET 3.5 adds several key new developer features including AJAX, LINQ, and a new CSS designer in Visual Web Developer 2008. The dramatic reduction in code that developers realized from the more than 50 new server controls in ASP.NET 2.0 now allows developers the time to make their applications more interactive with AJAX, to work with data in their preferred language with LINQ, and to build visually attractive and consistent standards-based sites with CSS. . | Chapter 8 Data Managementwith ADO.NET span id DataList1_ctl00_CompanyNameLabel Alfreds Futterkiste span br br td tr tr td CompanyName span id DataList1_ctl01_CompanyNameLabel Ana Trujillo Emparedados y helados span br br td tr -- Code removed for clarity -- table Although this table layout is the default you can change this so that the DataList control outputs span tags instead. This is done through the use of the RepeatLayout property of the DataList control. You will need to rework your DataList as is shown in Listing 8-19. Listing 8-19 Changing the output style using RepeatLayout asp DataList ID DataList1 runat server DataSourceID SqlDataSource1 RepeatLayout Flow ItemTemplate Company Name asp Label ID CompanyNameLabel runat server Text Eval CompanyName br br ItemTemplate asp DataList The possible options for the RepeatLayout property are either Table or Flow. Table is the default setting. The output you will get when looking at the source of the page when using the Flow setting is presented here span id DataList1 span CompanyName span id DataList1_ctl00_CompanyNameLabel Alfreds Futterkiste span br br span br span CompanyName span id DataList1_ctl01_CompanyNameLabel Ana Trujillo Emparedados y helados span br br span 406 Chapter 8 Data Managementwith ADO.NET -- Code removed for clarity -- span Working with Other Layout Templates You will find that the other templates are just as easy to work with as the ItemTemplate. Listing 8-20 shows you how to add the AlternatingItemTemplate and the SeparatorTemplate to the company name display. Listing 8-20 Using both the AlternatingItemTemplate and the SeparatorTemplate @ Page Language VB AutoEventWireup false CodeFile DataListControl.aspx.vb Inherits DataListControl html xmlns http www.w3.org 1999 xhtml head runat server title DataList Control title head body form id form1 runat server div asp DataList ID DataList1 runat server DataSourceID SqlDataSource1 ItemTemplate Company Name asp Label ID CompanyNameLabel runat server .