Exemplo n.º 1
0
		protected override void CreateChildControls() 
		{
			Controls.Clear();
				
			if ((RepeatCount > 0) && (itemTemplate!=null))
			{
				// Start by outputing the header template (if supplied).
				if(headerTemplate != null)
				{
					SimpleRepeaterItem headerContainer = new SimpleRepeaterItem(0, RepeatCount);
					headerTemplate.InstantiateIn(headerContainer);
					//headerContainer.DataBind();
					Controls.Add(headerContainer);
				}

				// Output the content the specified number of times.
				for (int i = 0; i<RepeatCount; i++)
				{
					SimpleRepeaterItem container = new SimpleRepeaterItem(i+1, RepeatCount);

					if ((i%2 == 0) && (alternatingItemTemplate != null))
					{
						// This is an alternating item and there is an alternating template.
						alternatingItemTemplate.InstantiateIn(container);
					}
					else
					{
						itemTemplate.InstantiateIn(container);
					}
					//container.DataBind();
					Controls.Add(container);
				}

				// Once all of the items have been rendered,
				// add the footer template if specified.
				if (footerTemplate != null)
				{
					SimpleRepeaterItem footerContainer = new SimpleRepeaterItem(RepeatCount, RepeatCount);
					footerTemplate.InstantiateIn(footerContainer);
					//footerContainer.DataBind();
					Controls.Add(footerContainer);
				}
			}
			else
			{
				// Show an error message.
				Controls.Add(new LiteralControl("Specify the record count and an item template"));
			}
		}
        protected override void CreateChildControls()
        {
            Controls.Clear();

            if ((RepeatCount > 0) && (itemTemplate != null))
            {
                // Start by outputing the header template (if supplied).
                if (headerTemplate != null)
                {
                    SimpleRepeaterItem headerContainer = new SimpleRepeaterItem(0, RepeatCount);
                    headerTemplate.InstantiateIn(headerContainer);
                    //headerContainer.DataBind();
                    Controls.Add(headerContainer);
                }

                // Output the content the specified number of times.
                for (int i = 0; i < RepeatCount; i++)
                {
                    SimpleRepeaterItem container = new SimpleRepeaterItem(i + 1, RepeatCount);

                    if ((i % 2 == 0) && (alternatingItemTemplate != null))
                    {
                        // This is an alternating item and there is an alternating template.
                        alternatingItemTemplate.InstantiateIn(container);
                    }
                    else
                    {
                        itemTemplate.InstantiateIn(container);
                    }
                    //container.DataBind();
                    Controls.Add(container);
                }

                // Once all of the items have been rendered,
                // add the footer template if specified.
                if (footerTemplate != null)
                {
                    SimpleRepeaterItem footerContainer = new SimpleRepeaterItem(RepeatCount, RepeatCount);
                    footerTemplate.InstantiateIn(footerContainer);
                    //footerContainer.DataBind();
                    Controls.Add(footerContainer);
                }
            }
            else
            {
                // Show an error message.
                Controls.Add(new LiteralControl("Specify the record count and an item template"));
            }
        }