Controlling a FormView in a RadWindow?

4 posts, 0 answers
  1. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 14 Aug 2015 Link to this post

    I have a FormView in the main page.  A button would allow me to do some processing and then bind a new datasource to the FormView.

    I couldn't get it to work though.  I am wondering is it because the formview is sitting in one AjaxPanel while the RadWindow has its own AjaxPanel.  I tried to use AjaxManager but same thing.

     Any sample would be appreciated.

     Thanks

  2. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 14 Aug 2015 Link to this post

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test4.aspx.cs" Inherits="Web.Test4" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <link rel="stylesheet" type="text/css" href="~/Style/general.css" />
        <link rel="stylesheet" type="text/css" href="~/Style/sidemenu.css" />
        <script type="text/javascript">
            function openwin() {
                var oWnd = $find("winAddPeople")
                oWnd.show();
            }

            function closewin() {
                var oWnd = $find("winAddPeople")
                oWnd.close();
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadAjaxManager runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="btnEdit111">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="fv" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="btnInsert111">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="fv" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

                <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptCombine="false" ScriptMode="Release">
                    <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" />
                        <asp:ScriptReference Path="~/Style/general.js" />
                    </Scripts>
                </telerik:RadScriptManager>
                <div class="container">
                    <div style="margin: 0px; width: 100%;" class="portfolio">
                        <div class="toplogobanner">
                            BANNER HERE
                        </div>
                        <div class="mainlayout">

                            <div class="leftmenu">
                                <div class="card">
                                    Menu here
                                </div>
                            </div>

                            <div class="maincontent">
                                <div class="card">
                                    <input type="button" value="Open Win" onclick="openwin();" />

                                    <asp:FormView runat="server" ID="fv" DefaultMode="ReadOnly">
                                        <ItemTemplate>
                                            THIS IS READ ONLY
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            THIS IS EDIT
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            THIS IS INSERT
                                        </InsertItemTemplate>
                                    </asp:FormView>

                                </div>
                            </div>
                        </div>


                    </div>
                </div>
            </telerik:RadAjaxPanel>


            <telerik:RadWindow ID="winAddPeople" runat="server" Width="360px" Height="400px">
                <ContentTemplate>
                    <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server">

                        <telerik:RadButton ID="btnEdit111" runat="server" Text="Edit" OnClick="btnEdit_Click" />
                        <telerik:RadButton ID="btnInsert111" runat="server" Text="Insert" OnClick="btnInsert_Click" />
                    </telerik:RadAjaxPanel>
                </ContentTemplate>
            </telerik:RadWindow>
        </form>
    </body>
    </html>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 14 Aug 2015 Link to this post

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;

    namespace Web
    {
        public partial class Test4 : System.Web.UI.Page
        {
            
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    var d = new Dictionary<string, string>();
                    d.Add("abc", "def");
                    fv.DataSource = d;
                    fv.DataBind();
                }
                else
                {
                }
            }


            protected void btnEdit_Click(object sender, EventArgs e)
            {
                var d = new Dictionary<string, string>();
                d.Add("abc", "def");
                fv.DataSource = d;
                fv.DataBind();
                fv.ChangeMode(FormViewMode.Edit);
            }

            protected void btnInsert_Click(object sender, EventArgs e)
            {
                var d = new Dictionary<string, string>();
                d.Add("abc", "def");
                fv.DataSource = d;
                fv.DataBind();
                fv.ChangeMode(FormViewMode.Insert);
            }
        }
    }
  5. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 19 Aug 2015 Link to this post

    Hello Edward,

    Please note also that using RadAjaxPanel simultaneously with RadAjaxManager or UpdatePanel ( or implementing multiple wrapped RadAjaxPanels ) is not a supported scenario and we highly recommend to avoid such implementation. Please either use just the manager to update your controls replacing the UpdatePanel / RadAjaxPanel with a regular asp:Panel, or use the UpdatePanel / RadAjaxPanel alone to wrap your page.

    That being said after fixing the ajaxification on your page and moving the RadScriptManager on the top of the form resolve the issues on my side. Take a look at the example:
    ASPX:
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptCombine="false" ScriptMode="Release">
            <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:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnEdit111">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="fv" />
                        <telerik:AjaxUpdatedControl ControlID="Panel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnInsert111">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="fv" />
                        <telerik:AjaxUpdatedControl ControlID="Panel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div class="container">
            <div style="margin: 0px; width: 100%;" class="portfolio">
                <div class="toplogobanner">
                    BANNER HERE
                </div>
                <div class="mainlayout">
     
                    <div class="leftmenu">
                        <div class="card">
                            Menu here
                        </div>
                    </div>
                    <div class="maincontent">
                        <div class="card">
                            <input type="button" value="Open Win" onclick="openwin();" />
     
                            <asp:FormView ID="fv" runat="server" AllowPaging="True" DataKeyNames="OrderID" DefaultMode="ReadOnly"
                                DataSourceID="FormViewDataSource" Width="300" Style="float: left;">
                                <ItemTemplate>
                                    OrderID:
                    <asp:Label ID="OrderIDLabel" runat="server" Text='<%# Eval("OrderID") %>'></asp:Label><br />
                                    CustomerID:
                    <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Bind("CustomerID") %>'>
                    </asp:Label><br />
                                    EmployeeID:
                    <asp:Label ID="EmployeeIDLabel" runat="server" Text='<%# Bind("EmployeeID") %>'>
                    </asp:Label><br />
                                    OrderDate:
                    <asp:Label ID="OrderDateLabel" runat="server" Text='<%# Bind("OrderDate") %>'></asp:Label><br />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    OrderID:
                    <telerik:RadTextBox ID="OrderIDTB" runat="server" Text='<%# Eval("OrderID") %>'></telerik:RadTextBox><br />
                                    CustomerID:
                    <telerik:RadTextBox ID="CustomerIDTB" runat="server" Text='<%# Bind("CustomerID") %>'>
                    </telerik:RadTextBox><br />
                                    EmployeeID:
                    <telerik:RadTextBox ID="EmployeeIDTB" runat="server" Text='<%# Bind("EmployeeID") %>'>
                    </telerik:RadTextBox><br />
                                    OrderDate:
                    <telerik:RadTextBox ID="OrderDateTB" runat="server" Text='<%# Bind("OrderDate") %>'></telerik:RadTextBox><br />
                                </EditItemTemplate>
                                <InsertItemTemplate>
                                    EmployeeID:
                    <telerik:RadTextBox ID="EmployeeIDTB2" runat="server" Text='<%# Bind("EmployeeID") %>'>
                    </telerik:RadTextBox><br />
                                    OrderDate:
                    <telerik:RadTextBox ID="OrderDateTB2" runat="server" Text='<%# Bind("OrderDate") %>'></telerik:RadTextBox><br />
                                </InsertItemTemplate>
                            </asp:FormView>
     
                            <asp:SqlDataSource runat="server" ID="FormViewDataSource" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                                ProviderName="System.Data.SqlClient" SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID],[OrderDate] FROM [Orders] WHERE ([CustomerID] = 'ALFKI')"
                                OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues"></asp:SqlDataSource>
     
                        </div>
                    </div>
                </div>
     
     
            </div>
        </div>
     
        <telerik:RadWindow ID="winAddPeople" runat="server" Width="360px" Height="400px">
            <ContentTemplate>
                <asp:Panel ID="Panel1" runat="server">
                    <telerik:RadButton ID="btnEdit111" runat="server" Text="Edit" OnClick="btnEdit_Click" />
                    <telerik:RadButton ID="btnInsert111" runat="server" Text="Insert" OnClick="btnInsert_Click" />
                </asp:Panel>
            </ContentTemplate>
        </telerik:RadWindow>
    </form>

    C#:
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        fv.ChangeMode(FormViewMode.Edit);
    }
     
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        fv.ChangeMode(FormViewMode.Insert);
    }


    Regards,
    Danail Vasilev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top