One of the simplest templated controls has to be the <asp:Repeater>
control. You give it an <ItemTemplate>
, provide data, and it renders. It doesn't get much simpler than that! An example of the <asp:Repeater>
control in action would be something like the following:
<asp:Repeater ID="productRepeater" runat="server"> <ItemTemplate> <asp:Image ImageUrl='<%# Eval("Image") %>' runat="server" /> <br /> <%# Eval("ProductName") %><br /> </ItemTemplate> </asp:Repeater>
By using the <%#
Eval()
%>
syntax, we set various properties of the controls or render the text to the website.
Which controls provide the most flexibility over layout and design?
Templated controls
Directly-bound controls
Simple controls
They're all the same
How do we bind data to a templated control?
DataSource
propertyDataSourceID
propertyFrom another object
Templated controls cannot display...