Updating Combobox after inserting record from radwindow

7 posts, 0 answers
  1. Carlos Gonzalez
    Carlos Gonzalez avatar
    5 posts
    Member since:
    May 2010

    Posted 31 Jul 2010 Link to this post

    Please help...losing my mind trying to get this to work.

    Simple scenario...

    Radcombo on rcb.aspx page with a button that opens rad window (works)
    radwindow has a form to enter new value to db (works)...upon closing the windows the radcombo should refresh, it's not even though record is successgully added to db.  I have looked through various examples and it should work but it's not

     <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="SqlDataSource1" />
                            <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>

    <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableViewState="false" AutoPostBack="true"
            DataSourceID="SqlDataSource1" DataTextField="CompanyName" DataValueField="CompanyID">
        </telerik:RadComboBox>
        <asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="False" />
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server" Behavior="Default" InitialBehavior="None"
                    Left="" NavigateUrl="clientwindow.aspx" OpenerElementID="Button1" Style="display: none;"
                    Top="" OnClientClose="ClientClose">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
        <telerik:RadCodeBlock runat="server">

            <script type="text/javascript">
                function openWindow() {
                    var oWnd = radopen("ClientWindow.aspx", "RadWindow1");
                    oWnd.setSize(495, 340);
                    var combo = $find("<%=RadComboBox1.ClientID %>");
                    //combo.setvalue("");
                }

                //        function selectedIndexChanging(sender, args) {
                //            if (args.get_item().get_value() == "-1")
                //                args.set_cancel(true);
                //        }

                function ClientClose(arguments) {
                    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                    ajaxManager.ajaxRequestWithTarget('<%= RadAjaxManager1.UniqueID %>', '');
                }
            </script>

        </telerik:RadCodeBlock>

    vb code:
    the codes executes but it seems the radcombo is not ajaxified
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            'Bind the RadComboBod


            RadComboBox1.DataSource = Nothing
            RadComboBox1.DataBind()
            SqlDataSource1.DataBind()
            RadComboBox1.DataSourceID = "SqlDataSource1"

            RadComboBox1.DataBind()
            ' RadComboBox1.

        End Sub

  2. Kiara
    Kiara avatar
    309 posts
    Member since:
    Jul 2006

    Posted 02 Aug 2010 Link to this post

    Carlos, I think that in the ClientClose method you should call the ajaxRequest method of the manager as follows:

    function ClientClose(arguments) {
                    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                    ajaxManager.ajaxRequest('');
    }

    This should fire the AjaxRequest server event to rebind the combobox to its source. Also debug and make sure that new records are added in the db before that.

    Hope this helps.

    Kiara
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Carlos Gonzalez
    Carlos Gonzalez avatar
    5 posts
    Member since:
    May 2010

    Posted 02 Aug 2010 Link to this post

    Thanks Kiara...I haven't tried yet but while waiting for an answer I did the following and it worked.

    I re-arranged my code as follows:

    RadCodeBlock
    ScriptManager
    RadAjaxManager
    ComboBox
    Button

    All other logic stayed the same and everything worked as expected.

    Thanks,
    Carlos
  5. jolynice
    jolynice avatar
    17 posts
    Member since:
    Jul 2009

    Posted 04 Aug 2010 Link to this post

    Hi Carlos Gonzalez

    I have the same problem, can you put here the sample code. Thanks

  6. Carlos Gonzalez
    Carlos Gonzalez avatar
    5 posts
    Member since:
    May 2010

    Posted 04 Aug 2010 Link to this post

    aspx code:
    <
    telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
     
           <script type="text/javascript">
               function openWindow() {
                   var oWnd = radopen("ClientWindow.aspx", "RadWindow1");
                   oWnd.setSize(495, 340);
                   var combo = $find("<%=RadComboBox1.ClientID %>");
                   //combo.setvalue("");
               }
     
               //        function selectedIndexChanging(sender, args) {
               //            if (args.get_item().get_value() == "-1")
               //                args.set_cancel(true);
               //        }
     
               function ClientClose(arguments) {
                   var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                   ajaxManager.ajaxRequestWithTarget('<%= RadAjaxManager1.UniqueID %>', '');
               }
           </script>
     
       </telerik:RadCodeBlock>
        
         <asp:ScriptManager ID="ScriptManager1" runat="server" />
          
           <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
               <AjaxSettings>
                   <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                       <UpdatedControls>
                           <telerik:AjaxUpdatedControl ControlID="SqlDataSource1" />
                           <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />
                       </UpdatedControls>
                   </telerik:AjaxSetting>
                   <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                       <UpdatedControls>
                           <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />
                       </UpdatedControls>
                   </telerik:AjaxSetting>
               </AjaxSettings>
           </telerik:RadAjaxManager>
          
       </div>
       <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VSSConnectionString %>"
           SelectCommand="SELECT [CompanyID], [CompanyName] FROM [tCompany] WHERE [BillTo] = 1 ORDER BY CompanyName">
       </asp:SqlDataSource>
       <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableViewState="false" AutoPostBack="true"
           DataSourceID="SqlDataSource1" DataTextField="CompanyName" DataValueField="CompanyID">
             </telerik:RadComboBox>

    VB Code:
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            'saw this in a different post that it could help    
            RadComboBox1.DataSource = Nothing
            RadComboBox1.DataBind()
            'no sure if this actually needed bu it worked for me
            SqlDataSource1.DataBind()
            RadComboBox1.DataSourceID = "SqlDataSource1"
     
            RadComboBox1.DataBind()
           
        End Sub
  7. jolynice
    jolynice avatar
    17 posts
    Member since:
    Jul 2009

    Posted 04 Aug 2010 Link to this post

    Hi Carlos.

    Thank you for the reply

  8. jolynice
    jolynice avatar
    17 posts
    Member since:
    Jul 2009

    Posted 05 Aug 2010 Link to this post

    Hi Carlos and everyone who have the same situation

    I found this example  working here,

    I am using the version 2010.1.519.35, and the example is for 2008.3.1105.35
    You need to change in the web.config
    line 75:

    <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.3.1105.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>

    for this one
    <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />

    I have a question, in this example does not existe the telerik:RadCodeBlock, do i have to use it wtith this example?

    Thanks
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017