A few days ago, Insus. NET has written the "dynamic binding data (GridView control Header and ItemTemplate)" http://www.cnblogs.com/insus/p/3303192.html article, but that is to implement the GridView control. According to previous rules, some netizens called Insus. NET implemented dynamic data binding using the Repeater control. Okay. Currently, Insus. NET uses the Repeater control to dynamically bind HeaderTemplater and ItemTemplate.
Use the data source from the previous article. Because they have the same fields.
Write the following in html markup:
The following describes how to bind data to the Repeater control:
When you dynamically bind HeaderTemplate and ItemTemplate, first obtain all column names from the Data source:
OK. Now we can write the OnItemDataBound = "RepeaterFruit_ItemDataBound" event:
To make it a success, preview it: