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

One more problem with AJAX in repeater.

1 Answer 84 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Kazimierz Szadkowski
Top achievements
Rank 1
Kazimierz Szadkowski asked on 14 Sep 2012, 02:18 PM
I have seen the Partial Ajaxification demo and it is almost what I need. In demo scenario each button in grid updates a single control outside of the grid. My scenario is slightly more complicated. Firstly I have two controls outside a repeater that should update themselves and some controls in repeater items. Controls in repeater items should update themselves, controls in other repeater items and also controls outside.
Structure looks somewhat like this:

<i:PeCa runat="server" ID="PicHolder"/>
<i:PeCa runat="server" ID="PicPartner"/>
<asp:Repeater ID="RptChildren" runat="server" OnItemDataBound="RptChildren_ItemDataBound"> <ItemTemplate> <iak:PeCa runat="server" ID="PicChild"/> </ItemTemplate> </asp:Repeater>

So PicHolder updates PicHolder, PicPartner and multiple PicChild in repeater. PicPartner updates PicPartner, PicHolder and PicChildren.  Each PicChild updates iteslf, other PicChild and PicPartner and PicHolder.
I understand I should construct ajax manager structure in codebehind, but it doesn work. I wanted to use AjaxUpdatedControlsCollection class to collect all updated controls, but I don't know which ID I should use. The same problem is when I create AjaxSetting for child inside repeater - what ID to use here? "PicChild"? Or should I use RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting method and add each control several times, for each control it updates?

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 19 Sep 2012, 10:51 AM
Hi Kazimierz,

You could access the repeater's items bu using the FindControl() method and add them separately to the RadAjaxManager settings. For example:

ASP:
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Button" />
<br />
<asp:Repeater ID="Repeater1"  runat="server">
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text="Item1"></asp:Label>
        <asp:Label ID="Label2" runat="server" Text="Item2"></asp:Label>
    </ItemTemplate>
</asp:Repeater>

C#:
protected void Page_Load(object sender, EventArgs e)
 {
     foreach (RepeaterItem item in Repeater1.Items)
     {
         Label lbl1 = (Label)item.FindControl("Label1");
         Label lbl2 = (Label)item.FindControl("Label2");
         RadAjaxManager.GetCurrent(Page).AjaxSettings.AddAjaxSetting(Button1, lbl1);
         RadAjaxManager.GetCurrent(Page).AjaxSettings.AddAjaxSetting(Button2, lbl2);
         RadAjaxManager.GetCurrent(Page).AjaxSettings.AddAjaxSetting(lbl1, lbl2);
 
     }
 }

I hope this helps.

All the best,
Maria Ilieva
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.
Tags
Ajax
Asked by
Kazimierz Szadkowski
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or