This is a migrated thread and some comments may be shown as answers.
Bind DataTable to a RadRotator
3 Answers 86 Views
This is a migrated thread and some comments may be shown as answers.
Pritam
Top achievements
Rank 1
Pritam asked on 11 Sep 2012, 02:22 PM
I added a telerik:RadTabStrip with multipageview option. Then under a pageview I added a Telerik Rotator control.
If I set static value it works fine, but, if I create a datatable in server side and try to bind it to datasource of the rotator control it does not display any data. The code I used -


ASPX Code:
<telerik:RadRotator ID="RadRotator1" runat="server" Width="900px" Skin="Black" EnableEmbeddedSkins="false"
                    CssClass="rotatorStyle" RotatorType="Buttons" ScrollDuration="500" >
                    <Items>
                        <telerik:RadRotatorItem>
                            <ItemTemplate>
                                <div class="RotatorItem">
                                    <h2><asp:Label ID="lblTitle" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "title") %>'></asp:Label></h2>
                                    <div class="txt_placeholder">
                                        <asp:Label ID="lblShortDesc" Text='<%# DataBinder.Eval(Container.DataItem, "desc")%>' runat="server"></asp:Label>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </ItemTemplate>
                        </telerik:RadRotatorItem>
                        
                    </Items>
                </telerik:RadRotator>


Server Code:

DataTable dt = new DataTable();
                    dt.Columns.Add("title", typeof(string));
                    dt.Columns.Add("desc", typeof(string));

                    dt.Rows.Add("T1", "AAA");
                    dt.Rows.Add("T2", "BBB");
                    dt.Rows.Add("T3", "CCC");

                    RadRotator1.DataSource = dt.DefaultView;
                    
                    RadRotator1.DataBind();

Can someone please help me with this?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 14 Sep 2012, 06:04 AM
Hi Pritam,

Try modifying your code as follows to add the items.

ASPX:
<telerik:RadRotator ID="RadRotator1" runat="server" Width="900px" CssClass="rotatorStyle" Skin="Black" EnableEmbeddedSkins="false" RotatorType="Buttons" ScrollDuration="500">
 <Items>
   <telerik:RadRotatorItem>
   </telerik:RadRotatorItem>
 </Items>
 <ItemTemplate>
   <div class="RotatorItem">
     <h2><asp:Label ID="lblTitle" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "title") %>'></asp:Label></h2>
     <div class="txt_placeholder">
       <asp:Label ID="lblShortDesc" Text='<%# DataBinder.Eval(Container.DataItem, "desc")%>' runat="server"></asp:Label>
     </div>
     <div class="clear">
     </div>
   </div>
 </ItemTemplate>
</telerik:RadRotator>

C#:
DataTable dt = new DataTable();
dt.Columns.Add("title", typeof(string));
dt.Columns.Add("desc", typeof(string));
dt.Rows.Add("T1", "AAA");
dt.Rows.Add("T2", "BBB");
dt.Rows.Add("T3", "CCC");
RadRotator1.DataSource = dt.DefaultView;
RadRotator1.DataBind();

Hope this helps.

Regards,
Princy.
0
Qurat
Top achievements
Rank 1
answered on 06 Apr 2013, 10:43 AM
hi,
i am trying to implement radrotator with images through database the link of the images is saved in the database.
no image is being displayed Please help.

0
Slav
Telerik team
answered on 10 Apr 2013, 08:31 AM
Hi Qurat,

I would suggest checking whether:

 - the DataSet, used for databinding the RadRotator, is not empty;
 - the path to the images is correct;
 - the images are available in the specified folder;

The rotator in the online demo Image Gallery is databound in the code-behind as well and the image source is set declaratively. You can use it as a reference for configuring the rotator on your end.

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.
Asked by
Pritam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Qurat
Top achievements
Rank 1
Slav
Telerik team
Share this question
or