Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:AddressItem"/> class.
 /// </summary>
 public AddressItem(EmployeeDB.BLL.Address entity)
     : base()
 {
     _entity = entity;
 }
Ejemplo n.º 2
0
        /// <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)
                    {
                        EmployeeDB.BLL.Address entity    = o as EmployeeDB.BLL.Address;
                        AddressItem            container = new AddressItem(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);
        }