About data binding problem of template columns generated in the background

zhaozj2021-02-16  79

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);

转载请注明原文地址:https://www.9cbs.com/read-12303.html

New Post(0)