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

SelectedIndex does not refresh control when using RadAjaxManager

2 Answers 235 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Cartoon Head
Top achievements
Rank 1
Cartoon Head asked on 18 Aug 2010, 03:49 PM
This could just be my ignorance on how the RadAjaxManager/client-side action works, but I'm having a problem getting the Combo Box selected value to change in a specific scenario using the RadAjaxManager.

In this demo, I'm just trying to set the third combo to whatever index the second one is set to.  This is not a desired production action, just a way to test whether the index is actually changing or not.  In all cases, the third combo includes more than the number of items in the second combo.

Using this code, the third combo box refreshes correctly, but I'm having the whole page refresh each time, as a result of the AutoPostBack's:

Default4.aspx.vb
Partial Class Default4
    Inherits System.Web.UI.Page
  
    Protected Sub cboInterventionTools_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles cboInterventionTools.SelectedIndexChanged
  
        cboInterventionDurations.SelectedIndex = cboInterventionTools.SelectedIndex
  
    End Sub
  
End Class


Default4.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default4.aspx.vb" Inherits="Default4" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
  
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
  
  
        <div>
  
            <asp:Panel ID="pnlMain" runat="server">
  
                Areas of Concern<br />
                <asp:SqlDataSource ID="sqlAreasOfConcern" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:RTIDesktop %>" 
                    SelectCommand="AreasOfConcern_List" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="1" Name="ContentAreaID" />
                    </SelectParameters>
                </asp:SqlDataSource>                                        
                <telerik:RadComboBox AutoPostBack="true" Height="300px" Width="200px" runat="server"
                    ID="cboAreasOfConcern" 
                    DataSourceID="sqlAreasOfConcern" DataTextField="AreaOfConcernName" 
                    DataValueField="AreaOfConcernID" ExpandDelay="0">
                </telerik:RadComboBox>
                <br />
              
                Intervention Tool<br />
                <asp:SqlDataSource ID="sqlInterventionTools" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:RTIDesktop %>" 
                    SelectCommand="InterventionTools_List" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="28172" Name="PersonID" />
                        <asp:ControlParameter ControlID="cboAreasOfConcern" Name="AreaOfConcernID" 
                            PropertyName="SelectedValue" />
                        <asp:Parameter DefaultValue="8" Name="GradeLevelID" />
                        <asp:Parameter DefaultValue="1" Name="DummyParameter" />
                    </SelectParameters>
                </asp:SqlDataSource>                                        
                <telerik:RadComboBox AutoPostBack="true" Height="300px" Width="200px" runat="server"
                    ID="cboInterventionTools" 
                    DataSourceID="sqlInterventionTools" DataTextField="InterventionToolName" 
                    DataValueField="InterventionToolID" ExpandDelay="0">
                </telerik:RadComboBox>
                <br />
  
                Intervention Duration<br />
                <asp:SqlDataSource ID="sqlInterventionDurations" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:RTIDesktop %>" 
                    SelectCommand="InterventionDurations_List" SelectCommandType="StoredProcedure">
                </asp:SqlDataSource>                                        
                <telerik:RadComboBox Height="300px" Width="200px" runat="server"
                    ID="cboInterventionDurations" 
                    DataSourceID="sqlInterventionDurations" DataTextField="InterventionDurationName" 
                    DataValueField="InterventionDurationID" ExpandDelay="0">
                </telerik:RadComboBox>
                <br />
          
            </asp:Panel>
              
        </div>
  
    </form>
</body>
</html>

Everything works great, the cboInterventionTools_SelectedIndexChanged() routine runs, and the cboInterventionDurations.SelectedIndex gets changed correctly.

If I add RadAjaxManager functionality, so that the screen doesn't refresh, the routine runs, but the combo control does not refresh:

Code added to Default4.aspx:
(right after the ScriptManager)
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="cboAreasOfConcern">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="cboInterventionTools" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

The idea is that any change to "Areas of Concern" automatically refreshes the "Intervention Tool", client-side. 

I need to be able to change the "Intervention Duration" to reflect a specific default duration time per tool.  It needs to make a call to SQL to determine that information.  If I embed that code into the cboInterventionTools_SelectedIndexChanged() routine, it all runs, and it even SETS the index correctly... but the control never changes visually on the screen.

Is there something I need to do to trigger that combo refresh, client-side, once the routine has completed?

2 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 18 Aug 2010, 06:54 PM
So what you're describing is this: If the user selects something from the cboAreasOfConcern, that you want the SelectedIndexChanged event of the cboInterventionTools to be raised, which in turn changes the selected index of cboInterventionDurations?

Did I get that right?

If so, you also need to include the third drop-down, cboInterventionDurations, in the UpdatedControls collection, in order for it to refresh that combobox. Although I doubt the SelectedIndexChanged event will raise if you select a value from cboAreasOfConcern, since it only affects the datasource that cboInterventionTools is bound to.

I hope that helps.
0
Cartoon Head
Top achievements
Rank 1
answered on 18 Aug 2010, 07:39 PM
I could have sworn I tried that at one point, at it didn't work.
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="cboAreasOfConcern">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="cboInterventionTools" />
                <telerik:AjaxUpdatedControl ControlID="cboInterventionDurations" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="cboInterventionTools">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="cboInterventionDurations" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>

But it is now.

So thanks for that.

I do realize I have to also handle it with a separate event call on the first combo, since it won't cascade down. 

But this appears to get the control to at least refresh properly.
Tags
ComboBox
Asked by
Cartoon Head
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Cartoon Head
Top achievements
Rank 1
Share this question
or