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

Updating Combobox after inserting record from radwindow

6 Answers 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Carlos Gonzalez
Top achievements
Rank 1
Carlos Gonzalez asked on 01 Aug 2010, 12:08 AM
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

6 Answers, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 02 Aug 2010, 11:27 AM
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
0
Carlos Gonzalez
Top achievements
Rank 1
answered on 02 Aug 2010, 08:46 PM
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
0
jolynice
Top achievements
Rank 1
answered on 04 Aug 2010, 10:31 PM
Hi Carlos Gonzalez

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

0
Carlos Gonzalez
Top achievements
Rank 1
answered on 04 Aug 2010, 10:45 PM
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
0
jolynice
Top achievements
Rank 1
answered on 04 Aug 2010, 10:58 PM
Hi Carlos.

Thank you for the reply

0
jolynice
Top achievements
Rank 1
answered on 05 Aug 2010, 04:40 PM
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
Tags
General Discussions
Asked by
Carlos Gonzalez
Top achievements
Rank 1
Answers by
Kiara
Top achievements
Rank 1
Carlos Gonzalez
Top achievements
Rank 1
jolynice
Top achievements
Rank 1
Share this question
or