views:

38

answers:

3

Maybe I'm having a brain fart or something because it seems like this should be pretty simple but how do you update a User Control from another User Control via Ajax?

I have an ASPX page with two user controls and when I trigger a server-side event on one, I want to refresh a grid on the other so it'll update it's data.

I'm using Telerik controls if that helps. Checkbox event on the first User Control causes the RadGrid in the second User Control to Rebind() and I have RadAjaxManager in the ASPX page and RadAjaxManagerProxy in the two User Controls.

A: 

An async callback will update the control that caused the postback and also any parent controls of its update panel. If your datagrid is not being updated in the browser after an event it would suggest its update method is not being called

Try calling the .update method of the datagrids updatepanel in the checkbox event

Dave
Do you know where I can see an example of this implementation?
EdenMachine
A: 

You could try using the ajaxRequest or ajaxRequestWithTarget client-side methods of the AjaxManager to initiate an ajax call. More info about these methods can be found on the Telerik's online documentation: http://www.telerik.com/help/aspnet-ajax/ajxclientsideapi.html

metalmkd
A: 

first for me Page.DataBind() dosn't work for me.

I declared in the UserControl

/ / Declare a delegate

public delegate void save_CommandEventHandler ();

/ / Event

save_CommandEventHandler SaveViewChanged public event;

here I run SaveViewChanged() from a click_button but can run from anywhere:

protected void save_Click (object sender, EventArgs e)

{

UpdateDataInDatabase();

SaveViewChanged ();

}

in page.aspx.cs code

protected override void OnInit (EventArgs e) {

    base.OnInit (e);

/ / UserControle1 is the Id of your UserControl declared in Aspx Page

    UserControle1.SaveViewChanged + =
    New UserControle.save_CommandEventHandler
    (Save_CommandEventHandler);
}

private void save_CommandEventHandler () {

  // Reload the gridView gvExpence to see the change operated in the user control

    gvExpence.DataSource =DataAcces.getAllCompanyExpence ();

    gvExpence.DataBind ();
   // update user control 2
   usercontrol2.updateView();

}
badre zouiri