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

How can I rebind my grid after a modal radwindow closes?

3 Answers 199 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Laura asked on 05 Nov 2008, 04:18 AM
I have a button outside my radgrid which when clicks, calls clientside javascript to open a modal radwindow and the window executes a wizard to create users for my grid. When the radwindow closes, I want the grid to rebind to show the new users. I have the window being created in the onclientclick event of the button. I also have an onclick server event handler for the button to rebind the grid, but it never gets executed. How can I rebind the grid after the window closes? I am attaching some code - hope it's enough....

aspx and Javascript:
   <div style="height:40px;width:50px;">
   <asp:Button  runat="server" id="WizardButton" style="width:170px;"  OnClientClick="openWin('<%# TextBoxOrderDetailID.Text %>'); return false;"   OnClick="rebindUsers" Text="Create Users"> </asp:Button>
   <telerik:RadWindowManager ID="wizardWindowManager"           
            Behaviors=" Move, resize, close" Modal="true" ReloadOnShow = "true" BackColor="AliceBlue" ForeColor ="AntiqueWhite" KeepInScreenBounds="true"  runat="server"  Skin="Office2007" VisibleStatusbar="false"  BorderColor="AliceBlue" >


 <telerik:RadGrid ID="usersGrid" runat="server"  
       DataSourceID="ContentCentralUsers" GridLines="None" Skin="Office2007" AutoGenerateColumns="False"
            ondatabound="usersGrid_DataBound" onitemdatabound="usersGrid_ItemDataBound"   OnItemCreated="usersGrid_ItemCreated"
            onitemevent="usersGrid_ItemDataBound" oniteminserted="usersGrid_ItemInserted" onitemupdated="usersGrid_ItemUpdated"
            ShowStatusBar="True" OnPreRender="usersGrid_PreRender" oninsertcommand="usersGrid_InsertCommand" OnItemCommand="usersGrid_ItemCommand"
            onupdatecommand="usersGrid_UpdateCommand"   >
       <MasterTableView  DataSourceID="ContentCentralUsers"  DataKeyNames="user_id,package_cd"
             AllowFilteringByColumn="True" AllowSorting="True"   
              InsertItemPageIndexAction="ShowItemOnFirstPage" CommandItemDisplay="Top"
             NoMasterRecordsText="No users to display.">
            <CommandItemSettings AddNewRecordText="Add new user"  />
        <telerik:GridEditCommandColumn ButtonType="ImageButton"  UniqueName="EditCommandColumn1">
                    <HeaderStyle Width="20px" />
        <telerik:GridBoundColumn DataField="user_id" UniqueName="user_id" Visible="false" ReadOnly="true" ></telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="package_cd" UniqueName="package_cd" Visible="false" ReadOnly="true" ></telerik:GridBoundColumn>

        <telerik:GridTemplateColumn HeaderText="Seat(User)" SortExpression="login_name" UniqueName="login_name" >
             <asp:Label ID="login_name"   runat="server"  Text='<%#Eval("login_name") %>'></asp:Label>
             <asp:TextBox ID="loginname" Text='<%#Eval("login_name") %>'  runat="server"  OnTextChanged="change_loginName"></asp:TextBox>
             <asp:RequiredFieldValidator id="loginnameRequiredFieldValidator" runat="server" ErrorMessage="* User name required" Display="Dynamic"
                ControlToValidate= "loginname"></asp:RequiredFieldValidator>
         <telerik:GridTemplateColumn HeaderText="Password" SortExpression="password" UniqueName="password"  EditFormColumnIndex="1" AllowFiltering="false">
             <asp:Label ID="password"   runat="server"  Text='<%#Eval("password") %>'></asp:Label></ItemTemplate>
              <asp:TextBox ID="editPassword" Text='<%#Eval("password") %>'  runat="server"  OnTextChanged="change_Password" ></asp:TextBox><asp:RequiredFieldValidator id="passwordRequiredFieldValidator" runat="server" ErrorMessage="* Password required" Display="Dynamic"
                  ControlToValidate= "editPassword"></asp:RequiredFieldValidator>
          </telerik:GridTemplateColumn><telerik:GridTemplateColumn HeaderText="Email" SortExpression="email" UniqueName="email" >
             <asp:Label ID="email"   runat="server"  Text='<%#Eval("email") %>'></asp:Label></ItemTemplate><EditItemTemplate>
             <asp:TextBox ID="editEmail" Text='<%#Eval("email") %>'  runat="server"  OnTextChanged="change_email"></asp:TextBox><asp:RequiredFieldValidator id="emailValidator1" runat="server" ErrorMessage="* Email required"    Display="Dynamic"
                 ControlToValidate= "editEmail"></asp:RequiredFieldValidator><asp:RegularExpressionValidator Runat="server" ErrorMessage="* Invalid E-mail Address" ID="emailValidator2"  Display="Dynamic"
                 ControlToValidate="editEmail" ValidationExpression=".+@.+\.[a-z]+"></asp:RegularExpressionValidator></EditItemTemplate></telerik:GridTemplateColumn><telerik:GridTemplateColumn HeaderText="Package"  UniqueName="DefaultPackage" EditFormColumnIndex="1" >
                       <HeaderStyle Width="100%" />
                            <asp:Label runat="server" ID="Label1" Text='<%#..........

function openWin(OrderDetailID) {

        var urlArgs = cbeGetURLArguments();

        var sbOID = parseInt(urlArgs['sbOID']);
        var queryODID = parseInt(urlArgs['sbODID']);
        var sbproductid = parseInt(urlArgs['sbproductid']);
        var SAPID = urlArgs['SAPID'];

        var txtbxODID = document.getElementById('TextBoxOrderDetailID').value;
        var txtbxProduct = document.getElementById('TextBoxProduct').value;
        var licensePrice = document.getElementById('licensePrice').value;
        if (txtbxODID == null)
            sbODID = queryODID;
            sbODID = txtbxODID;

        var windowURL = "v8Wizard_1.aspx?sbODID=" + sbODID + "&sbproductid=" + sbproductid + "&SAPID=" + SAPID +
                 "&lPrice=" + licensePrice + "&email=" + "" + "&ttt=" + "" + "&p_cd=" + "NTB" + "&sbOID=" + sbOID + "&numUsers=&packagePrice=0";

        var oWnd = radopen(windowURL, "RadWindow1");
        oWnd.setSize(650, 500);
        // oWnd.setSize(650, 600);;

        //set a function to be called when RadWindow is closed
    function OnClientClose(oWnd) {


    C#: but this is never getting executed
 protected void rebindUsers(Object sender, EventArgs e)
        TextBoxOrderDetailID.Text = Session["orderDetailID"].ToString();

3 Answers, 1 is accepted

Sort by
Top achievements
Rank 2
answered on 06 Nov 2008, 10:43 AM
Hi Laura,

Add "OnClientClose" event for RadWindow, and then call the AjaxRequest. At the server side you can rebind the RadGrid from the "RadAjaxManager1_AjaxRequest" method. Please try the following code snippets.

<telerik:RadWindowManager ID="RadWindowManager1" runat="server"
            <telerik:RadWindow runat="server" OnClientClose="closeRadWindow" Behavior="Default" InitialBehavior="None"  
                Left="" NavigateUrl="window.aspx" OpenerElementID="Button1"  
                style="display:none;" Top=""

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  
            <telerik:AjaxSetting AjaxControlID="RadGrid1"
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
<script type="text/javascript"
function closeRadWindow() 
 //   alert("RadWindow closed"); 
    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();  

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 

Top achievements
Rank 1
answered on 06 Nov 2008, 03:41 PM
Thank you. That helps alot. My grid now rebinds. I also had to change code in the part that closes the window. I needed to call the javascript code from the c# codebehind when the button to save and close the window so that the users would get saved first and then the window closes so the rebind has the new users to work with.

Now, after the modal window closes and before the rebind takes place, I get this error:

Error:Sys.ArgumentUndefinedException:value cannot be undefined. Parameter name: handler
 I click no I don't want to debug, and then the grid rebinds fine, but what would be causing that error?

Thanks for you help,
Telerik team
answered on 07 Nov 2008, 07:48 AM
Hello Laura,

Based on the supplied information, it is hard to determine what is causing the issue at hand.
If it persists, you can open a formal support ticket, and send us a small project, demonstrating the setup, and the unwanted behavior, for additional review.

All the best,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 2
Top achievements
Rank 1
Telerik team
Share this question