This is a migrated thread and some comments may be shown as answers.

Add charts to rad rotator

1 Answer 65 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Covertix
Top achievements
Rank 1
Covertix asked on 22 Feb 2012, 01:19 PM
Hi,

I want to create a RadRotator with Charts (asp.net charting) inside.

I tried a lot of ways to create it, but I couldn't see the charts inside.

the first option:

ascx:

 

<telerik:RadRotator ID="RadRotator1" runat="server" RotatorType="Buttons"

 

 

style="width:300px; height:300px; margin-left:10px; margin-top:30px;" ScrollDuration="500" FrameDuration="2000" ItemHeight="100" ScrollDirection="Up, Down"

 

 

ItemWidth="100">

 

 

    <ItemTemplate>

 

 

    </ItemTemplate>
</telerik:RadRotator >

cs:

Chart chart = new Chart():
// adding chart styles, etc.
RadRotator1.Items.Add(new RadRotatorItem(chart))


second option:

 

 

<telerik:RadRotator ID="RadRotator1" runat="server" RotatorType="Buttons"

 

 

 

 

 

style="width:300px; height:300px; margin-left:10px; margin-top:30px;" ScrollDuration="500" FrameDuration="2000" ItemHeight="100" ScrollDirection="Up, Down"

 

 

 

 

 

ItemWidth="100" OnItemCreated="RadRotator1_ItemCreated">

 

 

 

 

 

    <ItemTemplate>

 

 

 

 

 

 

 

 

        <asp:Chart ID="crtAlerts" runat="server" style="width:100px; Height:100px; margin-top:3px; margin-left:60px">

 

        </asp:Chart

 

    </ItemTemplate>

 

 

 

 

 

</telerik:RadRotator>

cs:

 

 

protected void RadRotator1_ItemCreated(object sender, Telerik.Web.UI.RadRotatorEventArgs e)

 

{

 

 

 

 

    Chart crtAlertsPerSZ = e.Item.FindControl("crtAlerts") as Chart;
    //adding styles to the chart, etc..
}

In this case, OnItemCreated is not fired.


Is there a way to add asp.net chart control to rad rotator?

Thanks.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 24 Feb 2012, 06:30 PM
Hello Tzach,

The first approach does not work because you should add the chart in the Controls collection of a newly created RadRotatorItem and then you need to insert this item in the Items collection of RadRotator, as shown below:
Chart chart = new Chart();
RadRotatorItem item = new RadRotatorItem();
item.Controls.Add(chart);
RadRotator1.Items.Add(item);

In your second approach you have only defined the template of the RadRotator's items, but you have not databound the control. As a result it is not populated with items and the server-side event ItemCreated is not raised. For example, if you populate it as demonstrated in the following example, the charts will be displayed, because the RadRotator control will have items in its collection:
RadRotator1.DataSource = new[] { "item", "item", "item" };
RadRotator1.DataBind();

Kind regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Rotator
Asked by
Covertix
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or