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

Rebind Grid in User Control from PopUp

3 Answers 218 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Lorenzo
Top achievements
Rank 1
Lorenzo asked on 07 Mar 2011, 01:00 PM
Hi,
I know I have the bad habit to put myself in complicated situations...., but it is not my fault, blame my customers ;-)

The Situation is as follows:
I have a Content Page which has as Master Page. Inside the content Page I load several User Controls. From one of the User Controls, which contains a RadGrid, I open a PopUp to edit the detail of the Grid. The PopUp contains a Button to save the detail and after saving I call a javascript function inside the Content Page (...actually inside the User Control) that triggers a AjaxCall to Rebind the Grid.
Everything works fine....only the first Time !!! 
After that the debugger of Firefox tells me that the RadAjax Manager does not exists. I have to reload the Content Page (not even the User Control) to have the Rebind working again.
I'm pasting here some code.

The Master Page has nothing special inside it besides a
<asp:ScriptManager runat="server" ID="ScriptManager"></asp:ScriptManager>
Beside that only HTML and CSS.


The Content Page:
<%@ Page Title="" Language="VB" MasterPageFile="~/App_Master/SystemSetup/SystemSetup_base.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="SystemSetup_Default" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_Top" Runat="Server">
    <telerik:RadToolBar ID="RadToolBar1" runat="server" Width="100%" Height="26px">
        <Items>
            <telerik:RadToolBarButton ImageUrl="Resources/Images/ico_Add_16.png"></telerik:RadToolBarButton>
            <telerik:RadToolBarButton Text="TEXT"></telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_Left" Runat="Server">
    <asp:button runat="server" ID="B_Eng" Text="ENG" Visible="false" />
    <asp:button runat="server" ID="B_Ita" Text="ITA" Visible="false" />
        <telerik:RadPanelBar ID="RadPanelBar" Runat="server" Width="100%" AllowCollapseAllItems="True" PersistStateInCookie="True">
            <Items>
                <telerik:RadPanelItem runat="server" Text='<%$ Resources:Menu_Item_1 %>' PostBack="false" Expanded="true" >
                    <Items>
                        <telerik:RadPanelItem runat="server" Value="~/SystemSetup/Admin/Setup/CompanyList.ascx" Text='<%$ Resources:Menu_Item_1_1 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Company_16.png" Selected="true"></telerik:RadPanelItem>
                        <telerik:RadPanelItem runat="server" Value="~/SystemSetup/Admin/Setup/OperatorList.ascx" Text='<%$ Resources:Menu_Item_1_2 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Users_16.png"></telerik:RadPanelItem>
                        <telerik:RadPanelItem runat="server" Value="~/SystemSetup/Admin/Setup/RoleList.ascx" Text='<%$ Resources:Menu_Item_1_3 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Role_16.png"></telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelItem>
                 
            </Items>
             
        </telerik:RadPanelBar>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder_Right" Runat="Server">
    <asp:Panel runat="server" ID="P_Body" Width="100%" Height="100%"></asp:Panel>
</asp:Content>

...and the code to load the controls.

Partial Class SystemSetup_Default
    Inherits System.Web.UI.Page
 
    Private Const CurrentControlKey As String = "CurrentControlKey"
 
    Private Property CurrentControl() As String
        Get
            Return IIf(ViewState(CurrentControlKey) = Nothing, "", ViewState(CurrentControlKey).ToString)
        End Get
        Set(ByVal value As String)
            ViewState(CurrentControlKey) = value
        End Set
    End Property
 
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        ' Controlla la versioen del Browser e caccai via se IE inferiore a 8
        If Request.Browser.Browser = "IE" AndAlso IsNumeric(Request.Browser.MajorVersion) AndAlso CInt(Request.Browser.MajorVersion) < 8 Then
 
            Dim Script As String = "alert('Plane è supportato solo da IE8 o versioni successive, Firefox e Chrome');"
            Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "Alert", Script, True)
        End If
 
        If Not IsPostBack Then
 
            CurrentControl = RadPanelBar.SelectedItem.Value
 
        End If
 
        Dim isNewControl As Boolean = Not CurrentControl.Equals(RadPanelBar.SelectedItem.Value)
        If isNewControl Then
            CurrentControl = RadPanelBar.SelectedItem.Value
        Else
            LoadUserControl(P_Body, CurrentControl, Not IsPostBack)
        End If
 
    End Sub
 
    Private Function LoadUserControl(ByVal parentControl As Control, ByVal newControlPath As String, Optional ByVal isFirstLoad As Boolean = False) As Control
 
 
        Dim control As Control = Page.LoadControl(newControlPath)
        control.ID = newControlPath.ToString.Replace("/", "_").Replace("~", "_").Replace(".", "_")
 
        'AddHandler TryCast(control, IASControl).GenericEvent, AddressOf Me.HandleGenericEvent
 
        If isFirstLoad Then
            control.EnableViewState = False
        End If
 
        parentControl.Controls.Clear()
        parentControl.Controls.Add(control)
 
        If isFirstLoad Then
            control.EnableViewState = True
            'TryCast(control, IASControl).FirstLoad(Nothing)
        End If
 
        Return control
 
 
    End Function
 
    Protected Sub RadPanelBar_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar.ItemClick
        If e.Item.Level = 1 Then
            LoadUserControl(P_Body, e.Item.Value, True)
        End If
 
 
    End Sub
 
End Class


The User Control.
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="CompanyList.ascx.vb" Inherits="SystemSetup_UserControls_Setup_CompanyList" %>
<script language="javascript" type="text/javascript">
    function RowDbClick(sender, eventArgs) {
        var IdCompany = sender.get_masterTableView().get_dataItems()[eventArgs.get_itemIndexHierarchical()].getDataKeyValue("IdCompany");
        var W = window.open('Admin/Setup/p_Company.aspx?IdCompany=' + IdCompany, '', 'width=800px,height=550px,resizable=1');
    }
 
     
    function Rebind(eventArgs) {
        var AjaxManager = $find("<%= RadAjaxManager.ClientID %>");
        AjaxManager.ajaxRequest('Rebind' + '|' + eventArgs);
         
    }
</script>
 
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid" UpdatePanelHeight="100%" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
 
<telerik:RadSplitter runat="server" Width="100%" Height="100%" Orientation="Horizontal">
     
    <telerik:RadPane runat="server" Height="32px">
     
        <telerik:RadToolBar ID="RadToolBar1" runat="server" Height="26px" Width="100%">
            <Items>
                <telerik:RadToolBarButton Text="::" Enabled="false" ></telerik:RadToolBarButton>
                <telerik:RadToolBarButton Text='<%$ Resources:RTB_New %>' PostBack="false" NavigateUrl="javascript:var W=window.open('UserControls/Setup/p_newCompany.aspx','','width=800px,height=550px')" ImageUrl="../../Resources/Images/ico_New_16.png"></telerik:RadToolBarButton>
                <telerik:RadToolBarButton Text='<%$ Resources:RTB_Delete %>' ImageUrl="../../Resources/Images/ico_Garbage_16.png"></telerik:RadToolBarButton>
            </Items>
        </telerik:RadToolBar>   
    </telerik:RadPane>
 
    <telerik:RadPane ID="RadPane1" runat="server" Height="100%">
        <telerik:radgrid runat="server" ID="RadGrid" Width="100%" Height="100%" AutoGenerateColumns="false" style="border:0;outline:none;" AllowMultiRowSelection="true">
  
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDbClick" />
                <Selecting AllowRowSelect="true" />
                <Scrolling AllowScroll="true" SaveScrollPosition="true" ScrollHeight="100%" UseStaticHeaders="true" />
            </ClientSettings>
          
            <MasterTableView style="border:0;outline:none;" DataKeyNames="IdCompany" ClientDataKeyNames="IdCompany">
                <Columns>
                     
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                            <asp:Image runat="server" ID="I_OnOff" ImageUrl='<%# IIF(Eval("Active") = true,"~/SystemSetup/Resources/Images/ico_On_16.png","~/SystemSetup/Resources/Images/ico_Off_16.png") %>' />
                        </ItemTemplate>
                         
                        <HeaderStyle Width="24px" />
                        <ItemStyle Width="24px" HorizontalAlign="Center" CssClass="AbsLeft"  />
                    </telerik:GridTemplateColumn>
                     
                    <telerik:GridBoundColumn DataField="DescrShort" HeaderText="Company">
                        <HeaderStyle HorizontalAlign="Center"/>
                         
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
             
        </telerik:radgrid>   
    </telerik:RadPane>
</telerik:RadSplitter>

The Rebind javascript is to Rebind the RadGrid. The code behind just says:

Protected Sub RadAjaxManager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager.AjaxRequest
       Select Case e.Argument.Split("|")(1)
           Case "RadGrid"
               RadGrid.Rebind()
       End Select
   End Sub


The PopUp that is opened by the User Control:
<%@ Page Title="" Language="VB" MasterPageFile="~/App_Master/SystemSetup/PopUp_1.master" AutoEventWireup="false" CodeFile="p_Company.aspx.vb" Inherits="SystemSetup_UserControls_Setup_p_Company" %>
 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_Top" Runat="Server">
    <telerik:RadToolBar ID="RadToolBar" runat="server" Width="100%" Height="26px">
        <Items>
            <telerik:RadToolBarButton Value="Save" ImageUrl="../../Resources/Images/ico_Save_16.png" Text='<%$ Resources:WebResources, Save_Text %>'></telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>
</asp:Content>
 
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder_Left" Runat="Server">
    <telerik:RadPanelBar ID="RadPanelBar" Runat="server" Width="100%" AllowCollapseAllItems="True" PersistStateInCookie="True">
        <Items>
            <telerik:RadPanelItem runat="server" Text='<%$ Resources:Menu_Item_1 %>' PostBack="false" Expanded="true">
                <Items>
                    <telerik:RadPanelItem runat="server" Value="~/SystemSetup/UserControls/Setup/CompanyList.ascx" Text='<%$ Resources:Menu_Item_1_1 %>' ImageUrl="~/SystemSetup/Resources/Images/ico_Company_16.png" Selected="true"></telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>
</asp:Content>
 
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder_Right" Runat="Server">
<div style="position:absolute;top:0px;left:0px;right:0px;height:26px">
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage" Width="100%" Height="26px" SelectedIndex="0">
        <Tabs>
            <telerik:RadTab Text="Generale" PageViewID="PV_General"></telerik:RadTab>
        </Tabs>
     </telerik:RadTabStrip>
</div>
<div style="position:absolute;top:26px;left:0px;right:0px;bottom:0px;">
    <telerik:RadMultiPage runat="server" ID="RadMultiPage" Width="100%" Height="100%" SelectedIndex="0" BackColor="White">
                                     
        <telerik:RadPageView runat="server" ID="PV_General" Width="100%">
             
            <div class="RadPageView_Form">
                <div style="width:100%">     
                    <table cellpadding="0px" cellspacing="0px" border="0px" style="width:100%;">
                        <tr>
                            <td class="Label">Attiva:</td>
                            <td class="Data"><asp:CheckBox runat="server" ID="CK_Active" /></td>
                            <td class="Label"></td>
                            <td class="Data"><telerik:RadTextBox runat="server" ID="RadTextBox2" Width="96%" DisabledStyle-BorderStyle="None" Enabled="false"></telerik:RadTextBox></td>
                        </tr>
                        <tr>
                            <td class="Label">Nome:</td>
                            <td class="Data"><telerik:RadTextBox runat="server" ID="T_1" Width="96%"></telerik:RadTextBox></td>
                            <td class="Label"></td>
                            <td class="Data"><telerik:RadTextBox runat="server" ID="T_2" Width="96%" DisabledStyle-BorderStyle="None" Enabled="false"></telerik:RadTextBox></td>
                        </tr>
                         
                    </table>
                </div>
                
            </div>
        </telerik:RadPageView>
        
     </telerik:RadMultiPage>
</div>
</asp:Content>

..and the code behind to Update and trigger the Rebind.
Imports System.Data
 
Partial Class SystemSetup_UserControls_Setup_p_Company
    Inherits System.Web.UI.Page
 
    Private IdCompany As Guid = Guid.Empty
 
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Request.QueryString("IdCompany") Is Nothing AndAlso Request.QueryString("IdCompany") <> "" Then
            IdCompany = New Guid(Request.QueryString("IdCompany"))
        End If
 
        If Not IsPostBack Then
            LoadItem()
        End If
    End Sub
 
    Private Sub LoadItem()
        Dim oDaOb As New RC.Protection.Company
        oDaOb.PK.Add("IdCompany", IdCompany)
 
        Dim oCo As DataRow = oDaOb.Get
 
        CK_Active.Checked = oCo("Active")
        T_1.Text = oCo("DescrShort")
    End Sub
 
    Protected Sub RadToolBar_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar.ButtonClick
        Select Case e.Item.Value
            Case "Save"
                If IdCompany <> Guid.Empty Then
                    Dim oDaOb As New RC.Protection.Company
                    Dim oCo As DataRow = oDaOb.newDaObItem
                    oCo("IdCompany") = IdCompany
                    oCo("DescrShort") = T_1.Text
                    oCo("Active") = CK_Active.Checked
 
                    oDaOb.Upd(oCo)
 
                    Rebind()
 
                End If
                 
        End Select
    End Sub
 
    Private Sub Rebind()
        Dim Script As String = "window.opener.Rebind('RadGrid');"
        Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "Rebind", Script, True)
    End Sub
 
     
End Class

So, to make a long story short, First Rebind ....works great...and then non more Rebind till Content Page full reload.

Any ideas ?
Thanks much as always.

Lorenzo

3 Answers, 1 is accepted

Sort by
0
Accepted
Iana Tsolova
Telerik team
answered on 10 Mar 2011, 10:24 AM
Hi Lorenzo,

This is because the RadAjaxManager is added in the dynamically loaded control. I suggest that you move it to the content page. Then in the user control Page_PreRender add the ajax settings dynamically as below:
protected sub Page_PreRender(sender as object, e as EventArgs) hanldes Me.PreRender
    Dim manager as RadAjaxManager = RadAjaxManager.GetCurrent(Page)
    manager.AjaxSettings.AddAjaxSetting(manager, RadGrid)
end sub


Regards,
Iana
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Lorenzo
Top achievements
Rank 1
answered on 18 Mar 2011, 10:37 AM
Hi lana,
I figured it out the same way (more or less...) and solved in a similar way.

Thanks for your as always precious help. Now I'm in a rush, but hope I'll be able to post the entire solution in the next days. May be someone else will benefit from it.

Thanks again 

Lorenzo
0
Martin Roussel
Top achievements
Rank 1
answered on 25 Oct 2012, 08:06 PM
Hi,
sorry for bringing back this "old" post but the original poster had pretty much the same situation than Im currently in (but provided solution doesnt seem to solve mine):

I have a Main page (not a Master Page) containing a child page (in a RadAjaxPanel/RadPane).. Inside the child page, I load several User Controls containing mostly one RadGrid each. In a control, I open a PopUp (new aspx) to edit the detail of the Grid...or to add new entries. Everything works as expected until the control does an ajaxRequest from the client-side. That request call itself works (the request server-side function is fired correctly) but the control starts having strange behavior after:

1-Subsequent "ScriptManager.RegisterStartupScript" calls no longer fire anything
2- Grid refreshing ( Grid.Rebind() ) let the grid stuck with RadAjaxLoadingPanel icon.

Without triggering the ajaxRequest, RegisterStartupScript and Grid.Rebind() are working fine.

Note that the code (modified lightly) was working perfectly before (when I had everything declarative without user controls). Also, I have the same issues either I have the user controls loaded into a RadTabStrip or added in a PlaceHolder or directly on the child page.

Here's my code:

Child page (aspx)
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
 
                 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="mngRequestStarted" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
                 </telerik:RadAjaxManager>
                 <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="WebBlue" />
 
<telerik:RadTabStrip runat="server" ID="RadTabStrip1" Skin="WebBlue" EnableDragToReorder="true" MultiPageID="RadMultiPag1" SelectedIndex="0"></telerik:RadTabStrip>
                    <telerik:RadMultiPage ID="RadMultiPag1" runat="server" Style="width:99.7%;border:2px;border-color:red;border-style:solid;" SelectedIndex="0" OnPageViewCreated="RadMultiPage1_PageViewCreated"></telerik:RadMultiPage>

Child Page (cs)
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
           
                RadTab rootTab = null;
                RadPageView pv = null;
 
                rootTab = new RadTab();
                RadTabStrip1.Tabs.Add(rootTab);
                rootTab.Text = "UserControl";
 
                pv = new RadPageView();
                pv.ID = rootTab.Text;
                RadMultiPag1.PageViews.Add(pv);
           }
      }
 
protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
        {
            string userControlName = e.PageView.ID + ".ascx";
 
            Control userControl = Page.LoadControl(userControlName);
            userControl.ID = e.PageView.ID + "_userControl";
 
            e.PageView.Controls.Add(userControl);
        }

User Control (ascx)
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserControl.ascx.cs" Inherits="PL.UserControl" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
 
         
        var gblRadAjaxManager = null;
 
 function PopError(message) {

    if (message == "" || message == " " ) {
        alert("An unexpected error has occured");
    }
    else {
        alert(message);
    }
}
          
 
        function OpenWindow(Mode) {
            
            
            if (Mode == 0) {
 
                setTimeout(function () {
                    
                    var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
                    ajaxManager.ajaxRequest("ID" + "|" + "" + "|" + 0 + "|" + -1);
                 
                }, 0);
 
            }
 
            var oWnd = $find("<%=RadWindow1.ClientID%>");
            oWnd.setUrl("PopUp.aspx");
            oWnd.add_pageLoad(function () { oWnd.set_status("  "); })
            oWnd.show();
 
        }
 
        function refreshGrid(arg) {
 
            if (gblRadAjaxManager == null) {
                setTimeout(function () {
                    gblRadAjaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
                    
                    if (gblRadAjaxManager != null) {
                        gblRadAjaxManager.ajaxRequest("GridRebind");
                        return;
                    }
                }, 1000);
            }
 
 
            if (gblRadAjaxManager != null) {
                
                gblRadAjaxManager.ajaxRequest("GridRebind");
            }
 
         
        }
 
    </script>
</telerik:RadCodeBlock>
 
 
                <telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server">
                    <AjaxSettings>
                        <telerik:AjaxSetting AjaxControlID="RadGrid5">
                            <UpdatedControls>
                                <telerik:AjaxUpdatedControl ControlID="RadGrid5" LoadingPanelID="RadAjaxLoadingPanel1" />
                            </UpdatedControls>
                        </telerik:AjaxSetting>
                    </AjaxSettings>
                </telerik:RadAjaxManagerProxy>
                <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="WebBlue" />
 
                        <br />
                            
                        <a id="RadGrid5_Anchor"></a>
 
                        <div class="WidgetContainer">
                            <div class="GridHeader">
                                <asp:Label ID="lblLabel" CssClass="GridHeaderLabel" runat="server" ></asp:Label>
                                <div >
                                    <asp:Label ID="RadGrid5_lbl" runat="server"></asp:Label>
                                </div>
                                <div >
                                    <asp:Image runat="server" ID="RadGrid5_ImageLogo" AlternateText="" ImageUrl="~/Images/Icons/logo small.PNG" Height="20px" Width="20px" BorderWidth="0"></asp:Image>
                                </div>
                            </div>
                            <telerik:RadGrid ID="RadGrid5" runat="server" PageSize="20" AllowPaging="false" Width="99.9%"
                                AllowSorting="True" AllowFilteringByColumn="false" AllowMultiRowSelection="false"
                                ShowGroupPanel="false" GridLines="None" ShowFooter="false" ShowHeader="true" GroupingEnabled="false"
                                Skin="WebBlue" EnableHeaderContextAggregatesMenu="false" EnableHeaderContextMenu ="false"
                                AutoGenerateColumns="false" EnableViewState="True"
                                OnItemCommand="RadGrid5_OnItemCommand" OnDetailTableDataBind="RadGrid5_DetailTableDataBind" OnNeedDataSource="RadGrid5_NeedDataSource"
                                OnGroupsChanging="RadGrid5_OnGroupsChanging" OnColumnsReorder="RadGrid5_OnColumnsReorder" OnItemDataBound="RadGrid5_OnItemDataBound"
                                OnPreRender="RadGrid5_PreRender">
                             
                                <MasterTableView HierarchyLoadMode="Client" Name="Master"
                                 CommandItemDisplay="Top" CommandItemSettings-ShowAddNewRecordButton="true"
                                 CommandItemSettings-ShowExportToExcelButton="true" CommandItemSettings-ShowExportToWordButton="true"
                                 CommandItemSettings-ShowExportToPdfButton="true" CommandItemSettings-ShowExportToCsvButton="true" AllowMultiColumnSorting="true"
                                 Caption="" ClientDataKeyNames="intID">
                                 
 
                                     <Columns>
                                            ...
                                      </Columns
 
                                            <DetailTables>
                                                <telerik:GridTableView ShowHeader="true" Name="Detail" AllowSorting="false" CssClass="GridDetailTable" ClientDataKeyNames="intID">
                                                   
                                                    <Columns>
                                                        ...
                                                    </Columns>  
                                                </telerik:GridTableView>
                                            </DetailTables>
 
                                </MasterTableView>
 
                                <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
 
                                        <ClientSettings EnablePostBackOnRowClick="false" AllowRowsDragDrop="false" AllowDragToGroup="false" AllowColumnsReorder="false" ReorderColumnsOnClient="false" ColumnsReorderMethod="Reorder">
                                            <Resizing AllowRowResize="False" EnableRealTimeResize="True" ResizeGridOnColumnResize="false" AllowColumnResize="true" AllowResizeToFit="true"/>
                                            <Animation AllowColumnReorderAnimation="false" AllowColumnRevertAnimation="true" />
                                            <Selecting AllowRowSelect="true"/>
                                            <ClientEvents OnRowClick="OnRowClick" OnRowContextMenu="RowContextMenu"></ClientEvents>
                                        </ClientSettings>
                                        
                                        <SortingSettings SortedBackColor="Azure" EnableSkinSortStyles="false" />
 
                               <GroupingSettings ShowUnGroupButton="true" />
 
                            </telerik:RadGrid>
                         
 
                            <telerik:RadWindowManager ID="RadWindowManager1" Modal="true" Skin="WebBlue" runat="server" EnableShadow="true" IconUrl="/Images/Icons/WindowIcon.png">
                             
                                <Windows>
                                    <telerik:RadWindow ID="RadWindow1" runat="server" Height="360px" Width="630px"
                                    ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" Behaviors="Close,Resize,Minimize,Pin,Maximize,Move"
                                      
                                    </telerik:RadWindow>
                                </Windows>
                            </telerik:RadWindowManager>
 
 
                        </div>
                    //</div> this was the problem I had...see UPDATE note at end of post

User Control (cs)
namespace PL
{
    public partial class UserControl : PL.BaseInheritControlPL.BaseInheritControlPL
    {
        private RadAjaxManager manager = null;
 
protected void Page_Load(object sender, EventArgs e)
        {
            manager = RadAjaxManager.GetCurrent(Page);
            manager.AjaxSettings.AddAjaxSetting(manager, RadGrid5, RadAjaxLoadingPanel1);
            manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager_AjaxRequest);
        }
 
protected void RadGrid5_OnItemCommand(object o, Telerik.Web.UI.GridCommandEventArgs e)
        {
        
                if (e.CommandName == RadGrid.InitInsertCommandName)
                {
                    e.Canceled = true;
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "mykey", string.Format("OpenWindow('{0}');", 0), true);
 
                }
 
        }
 
protected void RadGrid5_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
 
                    RadGrid5.DataSource = LoadData();
 
 
                if (RadGrid5.DataSource == null)
                {
                    RadGrid5.DataSource = new string[] { };
                }
             
 
        }
 
protected void RadGrid5_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            if (e.DetailTableView.ParentItem.DataItem != null)
            {
                e.DetailTableView.DataSource = ((objectDTO)e.DetailTableView.ParentItem.DataItem).col;
            }
 
        }
 
private void RefreshGrid()
        {
 
             RadGrid5.DataSource = LoadData();
 
            RadGrid5.Rebind();
        }
 
protected void RadAjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            if (e.Argument == "GridRebind")
            {
                RefreshGrid();
            }
 
            if (e.Argument.IndexOf("ID|") == 0)
            {
                string[] postBackData = e.Argument.Split('|');
 
                    UpdateData(postBackData[1]));
            
 
            }
 
protected void UpdateData(string strID)
        {
 
            try
            {
 
                strResultMessage = SaveData(strID, "NEW DATA");
 
 
                if (strResultMessage != "")
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "mykey", string.Format("PopError('{0}');", strResultMessage), true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "mykey", "refreshGrid();", true);
                }
 
            }
            catch
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "mykey", "PopError('');", true);
            }
 
        }
    }
}
 
}

Popup (aspx)
<script type="text/javascript">
 
        function CloseAndRebind(args) {
            GetRadWindow().BrowserWindow.refreshGrid(args);
            GetRadWindow().close();
        }
 
        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;
        }
 
        function CloseWindow() {
            GetRadWindow().close();
        }
 
      
 
    </script>
 
<telerik:RadTextBox ID="txt" runat="server" Skin="WebBlue" MaxLength="4000" TextMode="MultiLine" Text="" Rows="10" Width="100%"></telerik:RadTextBox>
 
<telerik:RadButton id="btnSave" runat="server"  ValidationGroup="Validation" text="Save" Skin="WebBlue" meta:resourcekey="btnSave" OnClick="Save" autopostback="true"></telerik:RadButton>
                 <telerik:RadButton id="btnClose" runat="server" text="Close" Skin="WebBlue" meta:resourcekey="btnClose" onclientclicked="CloseWindow" autopostback="false"></telerik:RadButton>

Popup (cs)
protected void Save(object sender, EventArgs e)
        {
 
            try
            {
                if (Page.IsValid)
                {
 
                        string strResultMessage = "";
 
                       
                        strResultMessage = SaveData(txt.Text);
                     
 
                    if (strResultMessage != "")
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "mykey", string.Format("PopError('{0}');", strResultMessage), true);
                    }
                    else
                    {
 
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "mykey", "CloseAndRebind();", true);
                    }
                }
            }
            catch
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "mykey", "PopError('');", true);
            }
 
        }




UPDATE:
Solved!... had a extra </div> that I forgot to remove at the end of  UserControl.ascx

I'll let the code there if it can help others wanting to do similar
Tags
Ajax
Asked by
Lorenzo
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Lorenzo
Top achievements
Rank 1
Martin Roussel
Top achievements
Rank 1
Share this question
or