.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);
{MyDataBinder (Container, LC, ColumnNames);}}} In the code above, I define a delegate templatedataDatabase to control the display output. Use the code:
this.Repeater1.DataSource = reader; this.Repeater1.HeaderTemplate = new ShowDataTemplate (ListItemType.Header, DataControlerType.Repeater, new ShowDataTemplateDelegate (TempHeader)); this.Repeater1.FooterTemplate = new ShowDataTemplate (ListItemType.Footer, DataControlerType.Repeater); this.Repeater1.ItemTemplate = new ShowDataTemplate (ListItemType.Item, DataControlerType.Repeater, new ShowDataTemplateDelegate (TempItem)); this.Repeater1.AlternatingItemTemplate = new ShowDataTemplate (ListItemType.AlternatingItem, DataControlerType.Repeater, new ShowDataTemplateDelegate (TempAlternatingItem)); this. Repeater1.DataBind (); private void TempHeader (object container, Literal lc, string [] columnNames) {int index = -1; lc.Text = "
"; foreach (String i in columnnames) {INDEX ; if (i == "ID") {Continue;} lc.text = "