.NET FX provides a method that uses template to control the Repeater's display at the program runtime.
I will not say more here, I can see the relevant information in MSDN. (Oh, I didn't do it.
)..
In fact, the Private Void LC_DATABINDINDING (Object Sender, Eventargs E) function, when the data in DataSource is backed, each bind is called, and we call this function once, we will complete the dynamic modification pattern through customization of this function: )
Here is the implementation of the code:
///
///
Datacontrolertype
///
summary>
public
ENUM
DataControlrtype {
///
///
Repeater
///
summary>
REPEATER,
///
///
Datalist
///
summary>
DataList,
///
///
DataGrid
///
summary>
DataGrid}
//
Public Delegate Void DataBinder (Object Container, Litral LC);
///
///
DataBinder Handler.
///
summary>
public
Delegate
Void
TemplatedataBinder
Object
Container, Litral LC,
String
ColumnNames;
///
///
Summary Description for Template.
///
summary>
public
Class
DataTemplateItem: itemplate {
Private
ListiteMType Templattype;
Private
String
[] columnnames
=
NULL
;
Private
Datacontrolrtype control;
public
TemplatedTabinder MyDataBinder
=
NULL
;
///
///
Constructor
///
summary>
///
param>
///
param>
///
param>
public
DataTemplateItem
String
[] ColumnNames, ListItemType TemplateType, Datacontrolertype ControlType) {Templattype
=
TemplateType; ColumnNames
=
ColumnNames; ControlType
=
ControlType;
///
///
///
summary>
///
param> ////
param>
///
param>
///
param>
public
DataTemplateItem
String
[] ColumnNames, ListItemType TemplateType, Datacontrolertype ControlType, TemplatedataBinder DataBinder) {MyDataBinder
=
DataBinder; TemplateType
=
TemplateType; ColumnNames
=
ColumnNames; ControlType
=
ControlType;
///
///
///
summary>
///
param>
///
param>
public
DataTemplateItem (ListItemType TemplateType) {TemplateType
=
TemplateType; ControlType
=
ControlType;
///
///
///
summary>
///
param>
///
param>
///
param>
public
DataTemplateItem (ListIntrolType Templatype, TemplatedATABINDER DATABINDER) {MyDataBinder
=
DataBinder; TemplateType
=
TemplateType; ControlType
=
ControlType;
public
Void
Instantiatein (System.Web.ui.Control Container) {Litral LC
=
New
Literal ();
IF
(MyDATABINDER)
==
NULL
) {
Switch
(Templattype) {
Case
ListitemType.Header: lc.text
= "