Create a user control with a template V.2, template v.2
The previous exercise "create a user control with template" http://www.cnblogs.com/insus/p/4161544.html. Too simplified. Usually, the Data Control Repeater has a webpage to write the Header, Item, AlternatingItem and Footer. To dynamically generate columns, We need to write a template in the background.
Review the Repeater controls dynamic change columns (Header, Item and Foot) Information http://www.cnblogs.com/insus/archive/2013/03/22/2974970.html. As the data changes, the name of the column changes, and only the dynamic implementation is required.
If a template does not have much impact, we can do it in the background.
Below we pull a Repeater control on the webpage:
After pulling the Repeater control, you must write headers, items, footer, and so on. Now there is no need to write anything for this pull, just like the GridView control. Because we have produced the content presented by the Repeater control in the background.
In this way, where are the bound content and fields written? It is written in the InsusTemplate custom template:
Running result:
OK. If you still want to obtain the Literal control value in xxx. aspx. cs, you can refer to the following method to obtain it. First, enable the OnItemDataBound feature in the Repeater control:
Repeaterincluitemdatabound event: