Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:VendorItem"/> class.
 /// </summary>
 public VendorItem(Nettiers.AdventureWorks.Entities.Vendor entity)
     : base()
 {
     _entity = entity;
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:VendorItem"/> class.
        /// </summary>
		public VendorItem(Nettiers.AdventureWorks.Entities.Vendor entity)
			: base()
		{
			_entity = entity;
		}
Esempio n. 3
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)
                    {
                        Nettiers.AdventureWorks.Entities.Vendor entity = o as Nettiers.AdventureWorks.Entities.Vendor;
                        VendorItem container = new VendorItem(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);
        }