Bind DataTable to a RadRotator

4 posts, 0 answers
  1. Pritam
    Pritam avatar
    3 posts
    Member since:
    Jul 2008

    Posted 11 Sep 2012 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Sep 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Qurat
    Qurat avatar
    21 posts
    Member since:
    Jan 2013

    Posted 06 Apr 2013 Link to this post

    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.

  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 10 Apr 2013 Link to this post

    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.
Back to Top