Create a simple full template server control step: 1. Define the container class to be used with the template control class.
2, use the ParseChilden feature tag control class, so that the HTML element in the template property can be parsed by the page analyzer;
3. Present the Itemplate type public property for each defined template;
4. Use the TemplateContainer feature to decorate the template properties, to notify the runtime when the template control type will be used; [TemplateContainer (TemplatedListItem)]
5. Creating a container class instance or child control instance, using the instantiatein method, and bind data to a container instance or child control instance, and finally add them to the server control set.
Incorporate
Dynamic Template: 1. Define a class to implement the Itemplate interface; 2. Implement the only method of Itemplate in this class Instantiatein;
Create a simple template data binding control step: 1, define controls that implement the InamingContainer interface;
2. Define the properties of the Itemplate type; the template's logical container (specified in the TemplateContainerattribute property) must have the properties to bind the data to. According to approximately
Declaration, this property name is DataItem
3. Rewrite the DataBind method (inherit from Control) to provide data binding logic. This operation must include the following steps: A: Call the ONDATABINDINDing method of the base class to call the handler for calculating data binding expressions for your control (additional). B: Clear the Controls collection. C: Clear the viewState of the child control. D: Create a child control using the data source. E: Send a signal to the ASP.NET page framework to track the viewState of the control.
4. Rewote CreateChildControls to re-create a child control in a flyback scheme. This involves clearing the Controls collection and using the view status rather than the data source creation control level
structure.
5. Define a data source with an empty element and use the data source when creating a control hierarchy during the rapid process is not a actual data source. Step 3 and 4 Use this data separately
Source and saved view status Create control hierarchies. Virtual Data Source makes a single code path for the control for the public elements of these two steps. (Method CreateControlhiRchy)