Window no close, no refresh Grid

8 posts, 0 answers
  1. Denis
    Denis avatar
    9 posts
    Member since:
    Mar 2014

    Posted 04 Apr 2014 Link to this post

    Hello

    I have two pages JobMatrix.aspx and Directories.aspx

    Not work when closing  or click Radbutton closing  - Window refresh Grid.
    Not work when clicking Radbutton update and closing window refresh Grid. 

    Thank you.


    JobMatrix.aspx
    ========================
    <%@ Page Title="" Language="C#" MasterPageFile="~/HomePage.master" AutoEventWireup="true" CodeFile="JobMatrix.aspx.cs" Inherits="Views_Home_JobMatrix" %>

    <asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="Server">
    </asp:Content>
    <asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="Server">
        <form id="Form_JobMatrix" runat="server">
            <telerik:RadScriptManager ID="RdScriptManager" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                </Scripts>
            </telerik:RadScriptManager>
            <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="true" />
            <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
            <telerik:RadCodeBlock ID="RdCodeBlock_JobMatrix" runat="server">
                <script type="text/javascript" src="../../JS/JS_GridJobMatrix.js"></script>
            </telerik:RadCodeBlock>
            <telerik:RadAjaxManager ID="RdAjaxManager_JobMatrix" runat="server" OnAjaxRequest="RdAjaxManager_JobMatrix_AjaxRequest">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RdAjaxManager_JobMatrix">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RdGrid_JobMatrix" LoadingPanelID="RdAjaxLoadingPanel_JobMatrix" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RdGrid_JobMatrix">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RdGrid_JobMatrix" LoadingPanelID="RdAjaxLoadingPanel_JobMatrix" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel runat="server" ID="RdAjaxLoadingPanel_JobMatrix"></telerik:RadAjaxLoadingPanel>
            <telerik:RadGrid ID="RdGrid_JobMatrix" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None">
                <PagerStyle Mode="NumericPages"></PagerStyle>
                <MasterTableView AutoGenerateColumns="False" Width="100%" CommandItemDisplay="Top" PageSize="5">
                    <Columns>
                        <telerik:GridBoundColumn DataField="ID" SortExpression="ID" HeaderText="ID" UniqueName="column_ID" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="catName" SortExpression="catName" HeaderText="КАТЕГОРИЯ" UniqueName="catName">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="catParent" SortExpression="catParent" HeaderText="ПОДКАТЕГОРИЯ" UniqueName="column_catParent">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="jName" SortExpression="jName" HeaderText="РАБОТА" UniqueName="column_jName">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="jmNeedApprove" SortExpression="jmNeedApprove" HeaderText="ОКЕЙ" UniqueName="column_jmNeedApprove">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="pName" SortExpression="pName" HeaderText="ДОЛЖНОСТЬ" UniqueName="column_dbuName">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="dbuName" SortExpression="dbuName" HeaderText="ИСПОЛНИТЕЛЬ" UniqueName="column_pName">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Manager" SortExpression="Manager" HeaderText="МЕНЕДЖЕР" UniqueName="column_dbuNameM">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="jmValid" SortExpression="jmValid" HeaderText="СТАТУС" UniqueName="column_jmValid">
                            <ItemStyle HorizontalAlign="Center" />
                            <FooterStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                    </Columns>
                    <CommandItemTemplate>
                        <a href="#" onclick="return ShowInsertForm();">Add New Record</a>
                    </CommandItemTemplate>
                </MasterTableView>
                <ClientSettings>
                    <Selecting AllowRowSelect="true"></Selecting>
                    <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
                </ClientSettings>
            </telerik:RadGrid>
            <telerik:RadWindowManager ID="RdWindowManager_JobMatrix" runat="server" EnableShadow="true">
                <Windows>
                    <telerik:RadWindow ID="RdWindow_editor" runat="server" Modal="True" Behaviors="Close, Move" Width="1000px" Height="600px" Title="JobMap РЕДАКТОР"
                        DestroyOnClose="True" NavigateUrl="Directories.aspx" Skin="Metro" EnableViewState="False" VisibleStatusbar="false"
                        ShowContentDuringLoad="false" ReloadOnShow="true">
                    </telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>
        </form>
    </asp:Content>


    Directories.aspx
    ==============================

    <%@ Page Title="" Language="C#" MasterPageFile="~/HomePage.master" AutoEventWireup="true" CodeFile="Directories.aspx.cs" Inherits="Views_Home_Directories" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

    <asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="Server">
    </asp:Content>
    <asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="Server">
        <form id="FormDirectories" runat="server">
            <div>
                <telerik:RadScriptManager ID="RdScriptManager" runat="server">
                    <Scripts>
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                    </Scripts>
                </telerik:RadScriptManager>
                <telerik:RadCodeBlock ID="RdCodeBlock" runat="server">
                    <script type="text/javascript" src="../../JS/JS_WinDirectories.js"></script>
                </telerik:RadCodeBlock>
                <telerik:RadFormDecorator ID="RdFormDecorator" runat="server" Skin="Vista" DecoratedControls="All" />
                <telerik:RadAjaxManager ID="RdAjaxManager_JobMatrix" runat="server"></telerik:RadAjaxManager>
                <telerik:RadAjaxPanel ID="RdAjaxPanel_Directory" runat="server" Height="100%" Width="100%">
                    <asp:Table ID="TableDirectories" runat="server">
                        <asp:TableRow>
                            <asp:TableCell>
                                КАТЕГОРИЯ
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_catName" runat="server" AutoPostBack="true" Skin="Metro" Width="200px" OnSelectedIndexChanged="RdComboBox_catName_SelectedIndexChanged">
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                ПОДКАТЕГОРИЯ
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_catParent" runat="server" Skin="Metro" Width="200px">
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                РАБОТА
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_jName" runat="server" Skin="Metro" Width="200px">
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                ОКЕЙ
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_jmNeedApprove" runat="server" Skin="Metro" Width="200px">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="" Value="-1" />
                                        <telerik:RadComboBoxItem Text="НЕТ" Value="0" />
                                        <telerik:RadComboBoxItem Text="ДА" Value="1" />
                                    </Items>
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                ДОЛЖНОСТЬ
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_pName" runat="server" Skin="Metro" Width="200px">
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                ИСПОЛНИТЕЛЬ
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_dbuName" runat="server" Skin="Metro" Width="200px">
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                МЕНЕДЖЕР
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_Manager" runat="server" Skin="Metro" Width="200px">
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                СТАТУС
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadComboBox ID="RdComboBox_jmValid" runat="server" Skin="Metro" Width="200px">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="" Value="-1" />
                                        <telerik:RadComboBoxItem Text="НЕ АКТИВНА" Value="0" />
                                        <telerik:RadComboBoxItem Text="АКТИВНА" Value="1" />
                                    </Items>
                                </telerik:RadComboBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                
                            </asp:TableCell>
                            <asp:TableCell>
                                <telerik:RadButton ID="RdButtonUpdate" runat="server" Text="Обновить" Skin="Metro" OnClick="RdButtonUpdate_Click"></telerik:RadButton>
                                <telerik:RadButton ID="RdButtonCancel" runat="server" Text="Отмена" Skin="Metro" OnClick="RdButtonCancel_Click"></telerik:RadButton>
                            </asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                </telerik:RadAjaxPanel>
            </div>
        </form>
    </asp:Content>


    JS_GridJobMatrix.js
    ===================

    function ShowEditForm(id, rowIndex) {
        var grid = $find("<%= RdGrid_JobMatrix.ClientID %>");

        var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
        grid.get_masterTableView().selectItem(rowControl, true);

        window.radopen("Directories.aspx?ID=" + id, "RdWindow_editor");
        return false;
    }
    function ShowInsertForm() {
        window.radopen("Directories.aspx", "RdWindow_editor");
        return false;
    }
    function refreshGrid(arg) {
        if (!arg) {
            $find("<%= RdAjaxManager_JobMatrix.ClientID %>").ajaxRequest("Rebind");
        }
        else {
            $find("<%= RdAjaxManager_JobMatrix.ClientID %>").ajaxRequest("RebindAndNavigate");
        }
    }
    function RowDblClick(sender, eventArgs) {
        window.radopen("Directories.aspx?ID=" + eventArgs.getDataKeyValue("ID"), "RdWindow_editor");
    }


    JS_WinDirectories.js
    =======================

    function CloseAndRebind(args) {
        GetRadWindow().BrowserWindow.refreshGrid(args);
        GetRadWindow().close();
    }
    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow;
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
        return oWindow;
    }
    function
        CancelEdit() {
        GetRadWindow().close();
    }

    C# code
    ===============================
    protected void RdButtonUpdate_Click(object sender, EventArgs e)
        {
            string _idJobM = Request.QueryString["ID"];

            string s_catName = RdComboBox_catName.SelectedValue.ToString();
            int i_catName;
            int.TryParse(s_catName, out i_catName);

            string s_catParent = RdComboBox_catParent.SelectedValue.ToString();
            int i_catParent;
            int.TryParse(s_catParent, out i_catParent);

            string s_dbuName = RdComboBox_dbuName.SelectedValue.ToString();
            int i_dbuName;
            int.TryParse(s_dbuName, out i_dbuName);

            string s_Manager = RdComboBox_Manager.SelectedValue.ToString();
            int i_Manager;
            int.TryParse(s_Manager, out i_Manager);

            string s_jName = RdComboBox_jName.SelectedValue.ToString();
            int i_jName;
            int.TryParse(s_jName, out i_jName);

            string s_jmNeedApprove = RdComboBox_jmNeedApprove.SelectedValue.ToString();
            int i_jmNeedApprove;
            int.TryParse(s_jmNeedApprove, out i_jmNeedApprove);

            string s_pName = RdComboBox_pName.SelectedValue.ToString();
            int i_pName;
            int.TryParse(s_pName, out i_pName);

            string s_jmValid = RdComboBox_jmValid.SelectedValue.ToString();
            int i_jmValid;
            int.TryParse(s_jmValid, out i_jmValid);

            sqlparams.Clear();
            if (_idJobM != null) { sqlparams.Add("@ID", _idJobM); }
            if (s_catName != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmCategory_ID", i_catName); }
            if (s_catParent != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmSubCategory_ID", i_catParent); }
            if (s_dbuName != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmDBUser_ID", i_dbuName); }
            if (s_Manager != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmManager_ID", i_Manager); }
            if (s_jName != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmJob_ID", i_jName); }
            if (s_jmNeedApprove != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmNeedApprove", i_jmNeedApprove); }
            if (s_pName != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmPosition_ID", i_pName); }
            if (s_jmValid != "-1") { sqlparams.Add(SqlDbType.Int, ParameterDirection.Input, "@jmValid", i_jmValid); }

            UniDataAdapter daUpdateJobMatrix = new UniDataAdapter(dsWEBSDESK, "tUpdateJobMatrix", "dbo.sp_UpdateJobMatrix", CommandType.StoredProcedure, sqlparams.GetParametrs());
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
        }
        protected void RdButtonCancel_Click(object sender, EventArgs e)
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", true);
        }



















  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Apr 2014 in reply to Denis Link to this post

    Hi Denis,

    I guess you are try to open editform through a window. Please take a look at this demo on Window - Window Editing.
    Please try and check with your code.

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Denis
    Denis avatar
    9 posts
    Member since:
    Mar 2014

    Posted 07 Apr 2014 in reply to Shinu Link to this post

    Hi Shinu, Thank you.

    But I use the same method and nothing gets
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Apr 2014 in reply to Denis Link to this post

    Hi Denis,

    Please correct your Directories.aspx page as below and check if it helps.

    ASPX:
    <telerik:RadScriptManager ID="RdScriptManager" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Vista" DecoratedControls="All" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <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 CancelEdit() {
                GetRadWindow().close();
            }  
        </script>
    </telerik:RadCodeBlock>
    <asp:Table ID="TableDirectories" runat="server">
    <%--Your code--%>
    </asp:Table>

    Thanks,
    Shinu
  6. Denis
    Denis avatar
    9 posts
    Member since:
    Mar 2014

    Posted 07 Apr 2014 in reply to Shinu Link to this post

    by clicking the button does not work
    protected void RdButtonUpdate_Click(object sender, EventArgs e)
        {
           === code update ===
                           === end code update === 
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
        }
        protected void RdButtonCancel_Click(object sender, EventArgs e)
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", true);
        }


  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Apr 2014 in reply to Denis Link to this post

    Hi Denis,

    I was not able to replicate the issue. Here is a sample code snippet I tried.

    SampleGrid.aspx
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function ShowEditForm(id, rowIndex) { 
                var grid = $find("<%= SampleGrid.ClientID %>");
                var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
                grid.get_masterTableView().selectItem(rowControl, true);
                window.radopen("EditForm.aspx?OrderID=" + id, "RdWindow_editor");
                return false;
            }
            function ShowInsertForm() {
                window.radopen("EditForm.aspx", "RdWindow_editor");
                return false;
            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" DefaultLoadingPanelID="RadAjaxLoadingPanel">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="SampleGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="SampleGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="SampleGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="SampleGrid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CellSpacing="0" GridLines="None" OnItemCreated="SampleGrid_ItemCreated" AllowPaging="true" PageSize="5">
        <MasterTableView AutoGenerateColumns="False" Width="100%" CommandItemDisplay="Top" DataKeyNames="OrderID">
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" SortExpression="OrderID" HeaderText="OrderID" UniqueName="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ShipCity" SortExpression="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                    <ItemTemplate>
                        <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
            <CommandItemTemplate>
                <a href="#" onclick="return ShowInsertForm();">Add New Record</a>
            </CommandItemTemplate>
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="true"></Selecting>
            </ClientSettings>
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="RdWindowManager_Sample" runat="server" EnableShadow="true">
        <Windows>
            <telerik:RadWindow ID="RdWindow_editor" runat="server" Modal="True" Behaviors="Close, Move"Width="500px" Height="400px" Title="Samplegrid" DestroyOnClose="True" Skin="Metro"VisibleStatusbar="false" ShowContentDuringLoad="false" ReloadOnShow="true">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT  * FROM [Orders]"></asp:SqlDataSource>

    SampleGrid.cs
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            SampleGrid.MasterTableView.SortExpressions.Clear();
            SampleGrid.MasterTableView.GroupByExpressions.Clear();
            SampleGrid.Rebind();
        }
        else if (e.Argument == "RebindAndNavigate")
        {
            SampleGrid.MasterTableView.SortExpressions.Clear();
            SampleGrid.MasterTableView.GroupByExpressions.Clear();
            SampleGrid.MasterTableView.CurrentPageIndex = SampleGrid.MasterTableView.PageCount - 1;
            SampleGrid.Rebind();
        }
    }
    protected void SampleGrid_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
            editLink.Attributes["href"] = "javascript:void(0);";
            editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"], e.Item.ItemIndex);
        }
    }

    EditForm.aspx
    <telerik:RadScriptManager ID="RdScriptManager" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <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 CancelEdit() {
                GetRadWindow().close();
            }  
        </script>
    </telerik:RadCodeBlock>
    <asp:Table ID="TableDirectories" runat="server">
        <asp:TableRow>
            <asp:TableCell>
            ShipCity
            </asp:TableCell>
            <asp:TableCell>
                <telerik:RadComboBox ID="RdComboBox_ShipCity" runat="server" AutoPostBack="true"  Skin="Metro" Width="200px" DataTextField="ShipCity" DataValueField="ShipCity" DataSourceID="SqlDataSource1">
                </telerik:RadComboBox>
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                <telerik:RadButton ID="RdButtonUpdate" runat="server" Text="Update" Skin="Metro" OnClick="RdButtonUpdate_Click">
                </telerik:RadButton>
                <telerik:RadButton ID="RdButtonCancel" runat="server" Text="Cancel" Skin="Metro" OnClick="RdButtonCancel_Click">
                </telerik:RadButton>
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT distinct [ShipCity] FROM [Orders]"></asp:SqlDataSource>

    EditForm.cs
    string _orderid;
    bool _isInsert, _isEdit;
    public static DataTable dtTable;
    SqlConnection SqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
    public SqlDataAdapter SqlDataAdapter = new SqlDataAdapter();
    public SqlCommand SqlCommand = new SqlCommand();
    protected void Page_Load(object sender, EventArgs e)
    {
        _orderid = Request.QueryString["OrderID"];
        if (Request.QueryString["OrderID"] == null)
        {
            _isInsert = true;
            _isEdit = false;
        }
        else
        {
            _isEdit = true;
            _isInsert = false;
        }
    }
    protected void RdButtonUpdate_Click(object sender, EventArgs e)
    {
        string _id = _orderid;
        string _shipCity = RdComboBox_ShipCity.SelectedValue.ToString();
        try
        {
            SqlConnection.Open();
            if (_isEdit)
            {
                string _updateQuery = "UPDATE Orders SET ShipCity ='" + _shipCity + "' WHERE OrderID = '" + _id + "'";
                SqlCommand.CommandText = _updateQuery;
            }
            else if (_isInsert)
            {
                string insertQuery = "INSERT into  Orders(ShipCity) values('" + _shipCity + "')";
                SqlCommand.CommandText = insertQuery;
            }
            SqlCommand.Connection = SqlConnection;
            SqlCommand.ExecuteNonQuery();
            SqlConnection.Close();
        }
        catch (Exception ex)
        {
     
        }
        finally
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
        }
    }
    protected void RdButtonCancel_Click(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", true);
    }

    Thanks,
    Shinu
  8. Denis
    Denis avatar
    9 posts
    Member since:
    Mar 2014

    Posted 08 Apr 2014 in reply to Shinu Link to this post

    when you press the script does not work, but everything is updated to the database. Not refreshing RadGrid, not refreshing Page.
  9. Denis
    Denis avatar
    9 posts
    Member since:
    Mar 2014

    Posted 08 Apr 2014 in reply to Denis Link to this post

    the problem was resolved by removing this code

    <%--<Scripts>
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                    </Scripts>--%>
     
      <%--<telerik:RadFormDecorator ID="RdFormDecorator" runat="server" Skin="Vista" DecoratedControls="All" />--%>
                <%--<telerik:RadAjaxManager ID="RdAjaxManager_JobMatrix" runat="server"></telerik:RadAjaxManager>--%>
               <%-- <telerik:RadAjaxPanel ID="RdAjaxPanel_Directory" runat="server" Height="100%" Width="100%">--%>
     
     
     
     <%--</telerik:RadAjaxPanel>--%>

    how to make that page did not blink? PostBack
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017