/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding) { int pos = 0; if (dataBinding) { //Instantiate the Header template (if exists) if (m_headerTemplate != null) { Control headerItem = new Control(); m_headerTemplate.InstantiateIn(headerItem); Controls.Add(headerItem); } if (dataSource != null) { foreach (object o in dataSource) { Nettiers.AdventureWorks.Entities.SalesOrderHeader entity = o as Nettiers.AdventureWorks.Entities.SalesOrderHeader; SalesOrderHeaderItem container = new SalesOrderHeaderItem(entity); if (m_itemTemplate != null && (pos % 2) == 0) { m_itemTemplate.InstantiateIn(container); if (m_seperatorTemplate != null) { m_seperatorTemplate.InstantiateIn(container); } } else { if (m_altenateItemTemplate != null) { m_altenateItemTemplate.InstantiateIn(container); if (m_seperatorTemplate != null) { m_seperatorTemplate.InstantiateIn(container); } } else if (m_itemTemplate != null) { m_itemTemplate.InstantiateIn(container); if (m_seperatorTemplate != null) { m_seperatorTemplate.InstantiateIn(container); } } else { // no template !!! } } Controls.Add(container); container.DataBind(); pos++; } } //Instantiate the Footer template (if exists) if (m_footerTemplate != null) { Control footerItem = new Control(); m_footerTemplate.InstantiateIn(footerItem); Controls.Add(footerItem); } } return(pos); }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding) { int pos = 0; if (dataBinding) { //Instantiate the Header template (if exists) if (m_headerTemplate != null) { Control headerItem = new Control(); m_headerTemplate.InstantiateIn(headerItem); Controls.Add(headerItem); } if (dataSource != null) { foreach (object o in dataSource) { Nettiers.AdventureWorks.Entities.SalesOrderHeader entity = o as Nettiers.AdventureWorks.Entities.SalesOrderHeader; SalesOrderHeaderItem container = new SalesOrderHeaderItem(entity); if (m_itemTemplate != null && (pos % 2) == 0) { m_itemTemplate.InstantiateIn(container); if (m_seperatorTemplate != null) { m_seperatorTemplate.InstantiateIn(container); } } else { if (m_altenateItemTemplate != null) { m_altenateItemTemplate.InstantiateIn(container); if (m_seperatorTemplate != null) { m_seperatorTemplate.InstantiateIn(container); } } else if (m_itemTemplate != null) { m_itemTemplate.InstantiateIn(container); if (m_seperatorTemplate != null) { m_seperatorTemplate.InstantiateIn(container); } } else { // no template !!! } } Controls.Add(container); container.DataBind(); pos++; } } //Instantiate the Footer template (if exists) if (m_footerTemplate != null) { Control footerItem = new Control(); m_footerTemplate.InstantiateIn(footerItem); Controls.Add(footerItem); } } return pos; }