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

RadAjaxManager with repeater not updating

1 Answer 160 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
JAVIER BABUGLIA
Top achievements
Rank 1
JAVIER BABUGLIA asked on 21 Sep 2018, 08:37 AM

Hello guys,

I'm having trouble updating textbox "A" thats inside a repeater from a button which gets some textbox "B" from is inside the repeater aswell.

First of all, the content of the textbox "A" is binded with DataBinder.Eval and I'm getting an error "The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>) " and I found a solution online by wraping the repeater with <telerik:RadCodeBlock runat="server">, is this the correct way of fixing it?

Here is my ajaxManager:

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">   
        <AjaxSettings>  
            <telerik:AjaxSetting AjaxControlID="listaDeElementos"> 
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="listaDeElementos" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings>  
        </telerik:RadAjaxManager> 

After I click the button, changes are actually made in the database but the repeater does not refresh. Nothing happens and I have to reload the page to actually see the changes. Here is my repeater:

 

    <telerik:RadCodeBlock runat="server" ID="radcode1">
             <asp:Repeater ID="listaDeElementos" runat="server" OnItemCommand="listaDeElementos_ItemCommand" >
             <ItemTemplate> 
                 <asp:TextBox runat="server" ID="txtMostrarComentario" Text='<%# string.Format("{0}", DataBinder.Eval(Container.DataItem, "Comentario")) %>'        enabled="false" TextMode="MultiLine" Width="65%" style="margin-top:10px;resize:none"></asp:TextBox>
                 <asp:TextBox runat="server" ID="txtComentario" Text=""  placeholder="Añadir comentario" TextMode="MultiLine" Width="33%" style="margin-top:10px;resize:none"></asp:TextBox>
                 <asp:Button ID="btnGuardarComentarioYnumeroDeSerie" runat="server" CommandArgument='<%# Eval("Id") %>' CommandName="GuardarComentarioYnumerodeserie"  Text="Guardar" Width="100%" CausesValidation="False" />
                  <br />
                 <hr />
              </ItemTemplate>
            </asp:Repeater>
      </telerik:RadCodeBlock>

So how do I make it update? 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 25 Sep 2018, 02:10 PM
Hi JAVIER,

Can you elaborate a bit on the exact way you are updating the textbox when the button is clicked? I tested an approach in which the TextBox text is updated with the CommandArgument of the clicked button and the update is performed successfully at my end. For convenience I am attaching my test page to this reply - can you test it and see if you reproduce the same problem with it? If it is working as expected, can you update it with your logic up to a point where the issue occurs and send it back for a further investigation?

in addition, you can also disable the AJAX on the page temporary in order to see if there are any client/server-side errors thrown on the page that are hidden by the AJAX update:
https://www.telerik.com/support/kb/aspnet-ajax/ajaxmanager/details/get-more-descriptive-errors-by-disabling-ajax

As for the RadCodeBlock usage - yes, this is the proper way to deal with such errors.

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Ajax
Asked by
JAVIER BABUGLIA
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or