The
CustCodeItemTemplate class does double duty by implementing both the ItemTemplate and
AlternatingItemTemplate templates for the Repeater control. The Boolean value passed to the
CustCodeItemTemplate templates??™ constructor in the web form??™s code behind file ensures they
have unique colors to make the output easy to read, as shown in Figure 7-11.
CHAPTER 7 ?– SERVER CONTROL DATA B INDING 327
Figure 7-11. The Dynamic Templates web form and CustCodeTemplates.cs
Listings 7-11 and 7-12 show the full code for the web form.
Listing 7-11. The DynamicTemplates .aspx Page File
<%@ Page Language="C#"
MasterPageFile="~/MasterPage/ControlsBook2MasterPage.Master"
AutoEventWireup="true" CodeBehind="DynamicTemplates.aspx.cs
" Inherits="ControlsBook2Web.Ch07.DynamicTemplates"
Title="Dynamic Templates Demo" %>
<%@ Register TagPrefix="apress" Namespace="ControlsBook2Lib.Ch07
Assembly="ControlsBook2Lib" %>
runat="server">
Width="14px">7ID="ChapterTitleLabel" runat="server" Width="360px">
Server Control Data Binding
328 CHAPTER 7 ?– SE RVER CONTROL DATA B INDING
Dynamic Templates
Template:
FileTemplate.
Pages:
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441