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

RadAjax not working with Repeater or Datalist

2 Answers 148 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 2
Matt asked on 01 Apr 2009, 09:42 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 01 Apr 2009, 12:13 PM
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.
0
Matt
Top achievements
Rank 2
answered on 01 Apr 2009, 02:40 PM
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.
Tags
Ajax
Asked by
Matt
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Matt
Top achievements
Rank 2
Share this question
or