Using RadAjaxManager to trigger a series of cascading combo boxes?

8 posts, 0 answers
  1. Cartoon Head
    Cartoon Head avatar
    21 posts
    Member since:
    Apr 2010

    Posted 02 Aug 2010 Link to this post

    Has anyone successfully used RadAjaxManager to trigger a series of cascading combo boxes?

    I have 3 RadCombo boxes setup, each with their own matching SQLDataSource.

    Changing cboContentAreas triggers a refresh of cboAreasOfConcern.
    Changing cboAreasOfConcern triggers a refresh of cboInterventionTools.

    However, changing cboContentAreas does NOT cause a refresh of cboInterventionTools as well.

    I thought maybe this would work (but it does not):
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cboContentAreas">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="cboAreasOfConcern" />
                    <telerik:AjaxUpdatedControl ControlID="cboInterventionTools" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="cboAreasOfConcern">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="cboInterventionTools" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    Is there a way to trigger a cascading refresh through the RadAjaxManager?

    I will also need to do a fourth level of refresh... when they select a tool, it will need to trigger a refresh of 3 other combo boxes.. and all of that needs to happen when the first combo is changed.

  2. Seth
    Seth avatar
    66 posts
    Member since:
    Oct 2009

    Posted 02 Aug 2010 Link to this post

    Can you post the rest of your aspx code?  It would be helpful to see how you have it all setup.
  3. Cartoon Head
    Cartoon Head avatar
    21 posts
    Member since:
    Apr 2010

    Posted 02 Aug 2010 Link to this post

    Default.aspx
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
      
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
      
    <!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>
      
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="cboContentAreas">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="cboAreasOfConcern" />
                        <telerik:AjaxUpdatedControl ControlID="cboInterventionTools" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cboAreasOfConcern">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="cboInterventionTools" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
      
        <div>
                     
            Content Area<br />
            <asp:SqlDataSource ID="sqlContentAreas" runat="server" 
                ConnectionString="<%$ ConnectionStrings:RTIDesktop %>" 
                SelectCommand="ContentAreas_List" SelectCommandType="StoredProcedure">
            </asp:SqlDataSource>                                        
      
            <telerik:RadComboBox AutoPostBack="true" Height="300px" Width="200px" runat="server"
                ID="cboContentAreas"
                DataSourceID="sqlContentAreas" DataTextField="ContentAreaName" 
                DataValueField="ContentAreaID" ExpandDelay="0">
            </telerik:RadComboBox>
            <br />
            <br />
              
            Areas of Concern<br />
            <asp:SqlDataSource ID="sqlAreasOfConcern" runat="server" 
                ConnectionString="<%$ ConnectionStrings:RTIDesktop %>" 
                SelectCommand="AreasOfConcern_List" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:ControlParameter ControlID="cboContentAreas" Name="ContentAreaID" 
                        PropertyName="SelectedValue" />
                </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:ControlParameter ControlID="hdnPersonID" Name="PersonID" 
                        PropertyName="Value" />
                    <asp:ControlParameter ControlID="cboAreasOfConcern" Name="AreaOfConcernID" 
                        PropertyName="SelectedValue" />
                    <asp:ControlParameter ControlID="hdnGradeLevelID" Name="GradeLevelID" 
                        PropertyName="Value" />
                </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 />
        </div>
          
        <asp:HiddenField ID="hdnPersonID" runat="server" />
        <asp:HiddenField ID="hdnGradeLevelID" runat="server" />
          
        </form>
    </body>
    </html>

    Default.aspx.vb
    Imports Telerik.Web.UI
      
    Partial Class Default2
        Inherits System.Web.UI.Page
      
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
            hdnPersonID.Value = CLng(28172)
            hdnGradeLevelID.Value = CLng(8)
      
        End Sub
      
    End Class


  4. Seth
    Seth avatar
    66 posts
    Member since:
    Oct 2009

    Posted 02 Aug 2010 Link to this post

    The problem is not with the AjaxManager, but with dependencies.  Because cboIntervnetionTools s not dependent directly on cboContentAreas, it does not get affected  when cboContentAreas is changed.

    Add a control parameter to sqlInterventionTools for cboContentAreas and it should work:

     

     

    <asp:ControlParameter ControlID="cboContentAreas" PropertyName="SelectedValue" />

  5. Cartoon Head
    Cartoon Head avatar
    21 posts
    Member since:
    Apr 2010

    Posted 02 Aug 2010 Link to this post

    OK, that's not a perfect solution, but it will work.

    Unless I'm mistaken, I need to give the parameter a name and then set up a matching "dummy" parameter in the SQL.
    <asp:SqlDataSource ID="sqlInterventionTools" runat="server" 
        ConnectionString="<%$ ConnectionStrings:RTIDesktop %>" 
        SelectCommand="InterventionTools_List" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="hdnPersonID" Name="PersonID" 
                PropertyName="Value" />
            <asp:ControlParameter ControlID="cboAreasOfConcern" Name="AreaOfConcernID" 
                PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="hdnGradeLevelID" Name="GradeLevelID" 
                PropertyName="Value" />
            <asp:ControlParameter ControlID="cboContentAreas" Name="DummyParameter" 
                PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>

    And then in the SQL declaration:
    ALTER PROCEDURE [dbo].[InterventionTools_List]
    (
     @PersonID           int
    , @AreaOfConcernID    int
    , @GradeLevelID       int
    , @DummyParameter     int = NULL  -- Not used, enables cascading combo boxes
    )
    AS
      
    (etc.)

    Again, not elegant, but under time constraints, I can live with that.

    Thank you!  It works perfectly now!
  6. Seth
    Seth avatar
    66 posts
    Member since:
    Oct 2009

    Posted 02 Aug 2010 Link to this post

    Glad it's working!

    You actually don't need the dummy parameter.  In my test I did not have one and it worked without it.
  7. Cartoon Head
    Cartoon Head avatar
    21 posts
    Member since:
    Apr 2010

    Posted 02 Aug 2010 Link to this post

    Doesn't work for me.  When I try this:
    <asp:SqlDataSource ID="sqlInterventionTools" runat="server" 
        ConnectionString="<%$ ConnectionStrings:RTIDesktop %>" 
        SelectCommand="InterventionTools_List" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="hdnPersonID" Name="PersonID" 
                PropertyName="Value" />
            <asp:ControlParameter ControlID="cboAreasOfConcern" Name="AreaOfConcernID" 
                PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="hdnGradeLevelID" Name="GradeLevelID" 
                PropertyName="Value" />
            <asp:ControlParameter ControlID="cboContentAreas" PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>

    I get as ASP error:

    Procedure or function InterventionTools_List has too many arguments specified.

    ... until I add that extra parameter to the SQL.
     And then I get:

    @ is not a parameter for procedure InterventionTools_List.

    ... until I give it a proper name on both sides.

    Using VS 2008 (Version 9.0.30729.1 SP) with .NET 3.5 SP1 and SQL 2008.

    Maybe something newer isn't as picky?  Or I've got a setting in VS 2008 or SQL that's telling it to be picky?
  8. Seth
    Seth avatar
    66 posts
    Member since:
    Oct 2009

    Posted 02 Aug 2010 Link to this post

    That might be it, I am using Framework 4.0.
Back to Top