RadAjax not working with Repeater or Datalist

3 posts, 1 answers
  1. Tony
    Tony avatar
    22 posts
    Member since:
    Jun 2005

    Posted 01 Apr 2009 Link to this post

    Hi,

    I have a simple page that has a Literal, a Repeater/Datalist and a DropDownList.  When there are no items in the Repeater the Literal is shown.  When an Item from the DropDownList is selected the Repeater is updated and the Literal is turned off.

    This scenario is a much simplified version of what am I trying to achieve, designed as proof of the error.  The page works fine with a full postback or when using a regular AJAX UpdatePanel, but when I try to use the RadAjax Manager, the Literal updates as expected, but the Repeater does not (I have tried replacing the Repeater with a Datalist and get the same results). 

    Here is some sample code...

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="DropDownList">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Literal" /> 
                        <telerik:AjaxUpdatedControl ControlID="Repeater " /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
              
        <div>  
            <ul> 
                <asp:Literal id="Literal" runat="server">This list is empty.</asp:Literal> 
                <asp:Repeater ID="Repeater" runat="server">  
                    <ItemTemplate> 
                        <li> 
                            <%#Container.DataItem("Item")%> 
                        </li> 
                    </ItemTemplate> 
                </asp:Repeater> 
            </ul> 
            <br /> 
            <div> 
                <asp:DropDownList ID="DropDownList" runat="server" AutoPostBack="true">  
                    <asp:ListItem Text="Item One" Value="1" /> 
                    <asp:ListItem Text="Item Two" Value="2" /> 
                    <asp:ListItem Text="Item Three" Value="3" /> 
                    <asp:ListItem Text="Item Four" Value="4" /> 
                    <asp:ListItem Text="Item Five" Value="5" /> 
                </asp:DropDownList>    
            </div> 
        </div> 

        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
            If Not IsPostBack Then 
                LoadList()  
            End If 
        End Sub 
     
        Sub LoadList()  
            Repeater.DataSource = "MyDataSource" 
            Repeater.DataBind()  
            If Repeater.Items.Count > 0 Then 
                Repeater.Visible = True 
                Literal.Visible = False 
            Else 
                Repeater.Visible = False 
                Literal.Visible = True 
            End If 
        End Sub 
     
        Protected Sub DropDownList_SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgs) Handles DropDownList.SelectedIndexChanged  
            'Add the Item here  
            LoadList()  
        End Sub 

    If I do this, it works...

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
            <ContentTemplate> 
                <div>  
                    <ul> 
                        <li id="Literal" runat="server">This list is empty.</li> 
                        <asp:Repeater ID="Repeater" runat="server">  
                            <ItemTemplate> 
                                <li> 
                                    <%#Container.DataItem("BusinessName")%> 
                                </li> 
                            </ItemTemplate> 
                        </asp:Repeater> 
                    </ul> 
                    <br /> 
                    <div> 
                        <asp:DropDownList ID="DropDownList" runat="server" AutoPostBack="true">  
                            <asp:ListItem Text="Item One" Value="17" /> 
                            <asp:ListItem Text="Item Two" Value="19" /> 
                            <asp:ListItem Text="Item Three" Value="20" /> 
                            <asp:ListItem Text="Item Four" Value="21" /> 
                            <asp:ListItem Text="Item Five" Value="22" /> 
                        </asp:DropDownList>    
                    </div> 
                </div>     
            </ContentTemplate> 
        </asp:UpdatePanel> 

    Any Ideas?
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Apr 2009 Link to this post

    Hello Tony,

    I tried the AjaxSetting as shown below and it is working fine for me. Give a try with the following code and see whether it working as expected.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">   
            <AjaxSettings>  
                <telerik:AjaxSetting AjaxControlID="DropDownList"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Repeater" /> 
                        <telerik:AjaxUpdatedControl ControlID="Literal" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings>  
    </telerik:RadAjaxManager> 

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tony
    Tony avatar
    22 posts
    Member since:
    Jun 2005

    Posted 01 Apr 2009 Link to this post

    Hi Shinu,

    Thanks for the response.

    I have no idea what I have done, but by recreating the RadAjax Manager it has started working!?  Maybe something got itself in a pickle somewhere?

    Sorry for the bother and thanks for the help.
Back to Top