Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Rotator > radrotator OnDataBound
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered radrotator OnDataBound

Feed from this thread
  • Stéphane avatar

    Posted on Dec 3, 2010 (permalink)

    Hi !
    I'm new to ASP.NET and Telerik and I can't find examples on how to use the "OnDataBound" event on the code-behind of my page. So I'm lost.
    Could you help me please ? This is my problem :

    I have this code on my page (vb.net) :

    <asp:Panel ID="PnlCDC" CssClass="BlocOccasionsCDC" runat="server" style="margin-bottom:20px;">
      <telerik:radrotator runat="server" id="radrotator1" Width="830px" Height="100px"
         ItemWidth="120px" ItemHeight="100px"
         ScrollDuration="1200"
         FrameDuration="2600"
         ScrollDirection="Left" ViewStateMode="Enabled" OnDataBound="radrotator1_databound" AppendDataBoundItems="true"
         AppendDataBoundItems="True" Skin="Black">
      <ItemTemplate>
         <asp:Panel ID="PanelBlocCDC" runat="server" CssClass="BlocCDC">
             <asp:Panel ID="PanelBlocCDCImage" runat="server" CssClass="BlocCDCImage">
                 <asp:HyperLink ID="HyperLinkCDC" runat="server" ToolTip="En savoir +" NavigateUrl="voiture-details.aspx?v=">
                     <asp:Image ID="ImageCDC" runat="server" Width="98px" Height="68px" BorderWidth="0" ImageUrl="~/voiture-photos/occasions/vide-small.png" />
                 </asp:HyperLink>
             </asp:Panel>
             <asp:Panel ID="PanelBlocCDCTexte" runat="server" CssClass="BlocCDCTexte">
                 <asp:Label ID="LabelBlocCDCTexte" runat="server" Text="" CssClass="TexteOccasionCDCsmall" />
             </asp:Panel> 
         </asp:Panel>   
      </ItemTemplate>
      </telerik:radrotator>  
     </asp:Panel>

    In my code behind I have this :
    Dim objOccasions As New Occasions
    radrotator1.DataSource = objOccasions.DataSetResultat
    radrotator1.DataBind()

    Occasions is an object I have created to manages an sql database of cars. DataSetResultat is a DataSet which contains the result of the sql request.
    What I would like to do, is something as the same as I can do with Gridview in VB.NET.
    I mean, I would like to manage the onrowdatabound event to be able to access the ASP.NET controls in my rotator for each item of the rotator and to add some personnal code to fill in their properties.

    To understand my problem, for example, with a classic gridview in vb.net, I can do this (I would like to do the same thing with the rotator but I'm not able to do it) :
    Code in my page :
    <asp:GridView ID="TarifsView"
               onrowdatabound = "TarifsView_RowDataBound"
               ....
    Code-behind of this page :
    Protected Sub TarifsView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles TarifsView.RowDataBound
            If e.Row.RowType = DataControlRowType.DataRow Then
      
                Dim objProd As New Products
                Dim ProdDesignation As Label = CType(e.Row.FindControl("LabelGammeTitreProduit"), Label)
                    ....

              end if
    End Sub

    But I'm not able to do the same thing with te radrotator.
    Could you help me by showing me examples so I could understand how to manage the event OnDataBound of the radrotator ?
    Thnak you very much for this.


  • Fiko Fiko avatar

    Posted on Dec 9, 2010 (permalink)

    Hello Stéphane,

    With RadRotator control you can use a similar approach in order to get reference to a control declared in its ItemTemplate:
    Protected Sub RadRotator1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadRotatorEventArgs) Handles RadRotator1.ItemDataBound
     
        Dim label1 As Label = CType(e.Item.FindControl("LabelGammeTitreProduit"), Label)
     
    End Sub


    This is the marlup of the rotator:
    <telerik:RadRotator ID="RadRotator1" runat="server" Width="100px" Height="100px"
        ItemHeight="100px" ItemWidth="100px" DataSourceID="xmlDataSource1">
        <ItemTemplate>
            <asp:Label ID="LabelGammeTitreProduit" runat="server" Text='<%# XPath("LabelText") %>'></asp:Label>
        </ItemTemplate>
    </telerik:RadRotator>
    <asp:XmlDataSource ID="xmlDataSource1" runat="server" DataFile="Thumbs.xml"></asp:XmlDataSource>


    Greetings,
    Fiko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Rotator > radrotator OnDataBound