Reference dynamically generated template column: public class DataGridTemplate: ITemplate {?? ListItemType templateType; ?? string columnName; ?? ?? public DataGridTemplate (ListItemType type, string colname) ?? {????? templateType = type; ??? ?? columnname = colname; ??}
?? public void instantiatein (system.web.ui.control container) ?? {????? literal lc = new literal (); ????? switch (TemplateType) ????? {???? ???? case listitemtype.Header: ??????????? lc.text = " colornname " "; ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ); ??????????? Break; ???????? case ListiteMTYPE.ITEM: ??????????? lc.text = "item" columnname ;? ?????????? container.controls.add (lc); ??????????? Break; ??????? case listitemType.editItem: ????? ?????? textbox TB = new textbox (); ??????????? tb.text = ""; ?????????????????????????????? ); ??????????? Break; ???????? case ListiteMTYPE.FOOTER: ??????????? lc.text = " colornname " " ; ??????????? container.controls.add (lc); ??????????? Break; ?????} ??}} http: // msdn. Example microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingtemplatesprogrammaticallyindatagridcontrol.asp bonding fields: lc.DataBinding = new System.EventHandler (BindLabelColumn)
...
Private void Bindlabelcolumn (Object Sender, Eventargs E) {?????? label lbl = (label) sender; ?????? DataGridItem Container = (DataGridItem) lbl.namingcontainer; ?????? lbl.text = DataBinder.eval (container.DataItem, Field1);