예제 #1
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 void CreateChildControls()
//		{
//			if (ChildControlsCreated)
//			{
//				return;
//			}
//			Controls.Clear();
//
//			if (m_headerTemplate != null)
//			{
//				Control headerItem = new Control();
//				m_headerTemplate.InstantiateIn(headerItem);
//				Controls.Add(headerItem);
//			}
//
//
//			if (m_footerTemplate != null)
//			{
//				Control footerItem = new Control();
//				m_footerTemplate.InstantiateIn(footerItem);
//				Controls.Add(footerItem);
//			}
//			ChildControlsCreated = true;
//		}

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