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

[Solved] Postback UserControl Bind Data

2 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Felipe Saldana
Top achievements
Rank 1
Felipe Saldana asked on 01 Apr 2009, 11:32 PM
I have created a user control that contains a RadGrid inside of it.

I need to perform a postback from the client to bind the data.  The following does postback but I need an event so that I know that the postback is indeed the "RefreshGrid"

                __doPostBack("<%= gvProperties.UniqueID %>", "RefreshGrid"); 

I have followed:

http://www.telerik.com/help/aspnet/grid/grdmakepostbackajaxrequestfromusercontrolwebformmasterpage.html

http://www.telerik.com/help/aspnet-ajax/grdpostbackfromgridwithajaxenabled.html

and those two don't deal with posting back to the same UserControl.

I have implemented the IPostBackEventHandler but it does not fire at all.


Felipe

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 06 Apr 2009, 12:12 PM
Hello Felipe,

To initiate on client-side grid to refresh itself, you can call this JavaScript method:
function RefreshGrid() 
  var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
  masterTable.rebind(); 
}  
For further information please review this link.

Best regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Felipe Saldana
Top achievements
Rank 1
answered on 06 Apr 2009, 03:42 PM
I ended up doing the following

called a radWindow that when a save button is clicked do this:

    void btn_Click(object sender, EventArgs e)  
    {  
        try 
        {  
            if (!string.IsNullOrEmpty(this.ddlKeyword.SelectedValue))  
            {  
                ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CloseAndRebind();"true);  
            }  
        }  
        catch (Exception ex)  
        {  
        }  
 
    }  
 
 
The javascript is below  
 
 
        function CloseAndRebind(args)  
        {  
            GetRadWindow().Close();  
            GetRadWindow().BrowserWindow.refreshGrid(args);  
        }  
          
        function GetRadWindow()  
        {  
            var oWindow = null;  
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog  
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)  
                  
            return oWindow;  
        } 

javascript on the control
           function refreshGrid(arg) {  
               if (!arg) {  
                   $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");  
               }  
               else {  
                   $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");  
               }  
           }  
 

server side on the control

    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)  
    {  
        if (e.Argument == "Rebind")  
        {  
            BindGrid();  
        }  
    } 

RadAjaxManager control
   <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"  > 

Tags
Grid
Asked by
Felipe Saldana
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Felipe Saldana
Top achievements
Rank 1
Share this question
or