"Pro ASP.NET 3.5 Server Controls and AJAX Components"
Figure 7-9. The Dynamic Templates web form and FileTemplate.ascx The actual code for the .ascx file is shown in Listing 7-10. Notice that we did not have to include the container tags. CHAPTER 7 ?– SERVER CONTROL DATA B INDING 325 Listing 7-10. The FileTemplate and CustFileTemplate .ascx Files <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FileTemplate.ascx.cs" Inherits="ControlsBook2Web.Ch07.FileTemplate" %> Contact:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustFileTemplate.ascx.cs" Inherits="ControlsBook2Web.Ch07.CustFileTemplate" %> Contact:
" />
Because the DropDownList control has the AutoPostBack property set to true, changing the template used by the Repeater control is as easy as selecting a different template in the DropDownList control. This causes a postback to occur and executes the code in LoadRepeater that is responsible for finding the right template and binding it to the Repeater control: string templateName = templateList.SelectedItem.Text; if (templateName.IndexOf(".