using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Telerik.WebControls;

public partial class RotatorDynamic : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable proverbsTable = new DataTable();
        proverbsTable.Columns.Add("proverb");
        proverbsTable.Rows.Add("A stitch in time saves nine");
        proverbsTable.Rows.Add("A rolling stone gathers no moss");
        proverbsTable.Rows.Add("The early bird catches the worm");
        proverbsTable.Rows.Add("A penny saved is virtually worthless");
        RadRotator rotator1 = new RadRotator();
        rotator1.ID = "rotator1";
        rotator1.DataSource = proverbsTable;
        rotator1.FrameTemplate = new RotatorTemplate("proverb");
        rotator1.TransitionType = RadRotator.RotatorTransitionType.Slideshow;
        rotator1.TransitionEffect = RadRotator.RotatorTransitionEffect.GradientWipe;
        rotator1.Width = 500;
        rotator1.Height = 50;
        rotator1.AutoPostBack = true;
        PlaceHolder1.Controls.Add(rotator1);
        rotator1.DataBind();

        DataTable colorsTable = new DataTable();
        colorsTable.Columns.Add("color");
        colorsTable.Rows.Add("Red");
        colorsTable.Rows.Add("Orange");
        colorsTable.Rows.Add("Yellow");
        colorsTable.Rows.Add("Green");
        colorsTable.Rows.Add("Blue");
        colorsTable.Rows.Add("Indigo");
        colorsTable.Rows.Add("Violet");
        RadRotator rotator2 = new RadRotator();
        rotator2.ID = "rotator2";
        rotator2.DataSource = colorsTable;
        rotator2.FrameTemplate = new RotatorTemplate("color");
        rotator2.TransitionType = RadRotator.RotatorTransitionType.Slideshow;
        rotator2.TransitionEffect = RadRotator.RotatorTransitionEffect.Pixelate;
        rotator2.Width = 500;
        rotator2.Height = 50;
        this.Controls.Add(rotator2);
        rotator2.DataBind();
    }
}

class RotatorTemplate : ITemplate
{
string columnName;
public RotatorTemplate(string column)
{
columnName = column;
}
public void InstantiateIn(Control c)
{
Label lbl = new Label();
lbl.DataBinding += new EventHandler(OnDisplayDataBinding);
c.Controls.Add(lbl);
}
void OnDisplayDataBinding(object sender, EventArgs e)
{
Label lbl = (Label)sender;
RadRotatorFrame iContainer = (RadRotatorFrame)lbl.NamingContainer;
DataRowView drv = ((DataRowView) iContainer.DataItem);
lbl.Text = drv[columnName].ToString();
lbl.BackColor = System.Drawing.Color.FromName(lbl.Text);
}
}
