Click here to Skip to main content
13,794,944 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I have a Editable ajaxtoolkit
its works perfectly fine with the no parameter SQL query

I want to use a parameter that has been called from another ajaxtoolkit control

I need you to help me , how pass parameter in Ajax ?

What I have tried:

<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div >
        <div class="col-md-12">
                <ajaxToolkit:ComboBox ID="CmbCountry"  AppendDataBoundItems="True" 
                    runat="server" AutoCompleteMode="Suggest" DataSourceID="SqlDataSource1" 
                    DataTextField="Country" DataValueField="Country" MaxLength="0" Style="left: auto; top: auto;">
                </ajaxToolkit:ComboBox>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:cs %>" 
                    SelectCommand="SELECT distinct Country from [StateMaster]"></asp:SqlDataSource>
        </div>
        <div class="col-md-12">
                <ajaxToolkit:ComboBox ID="ComboBox1"  
                    AppendDataBoundItems="True" runat="server" AutoCompleteMode="Suggest" 
                    DataSourceID="SqlDataSource2" DataTextField="State" 
                    DataValueField="State" 
                    MaxLength="0" Style="left: auto; top: auto;">
                </ajaxToolkit:ComboBox>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:cs %>" 
                    SelectCommand="SELECT distinct State from [statemaster] where [Country]=@Country">
                    <SelectParameters>
                 <asp:ControlParameter ControlID="cmbCountry" Name="Country" PropertyName="SelectedValue" Type="String" DefaultValue="Country" />
                                        </SelectParameters>
                </asp:SqlDataSource>
            
        </div>
        <div class="col-md-12">
                <ajaxToolkit:ComboBox ID="ComboBox2"  AppendDataBoundItems="True" 
                    runat="server" AutoCompleteMode="Suggest" 
                    DataSourceID="SqlDataSource3" DataTextField="State" 
                    DataValueField="State" MaxLength="0" Style="left: auto; top: auto;">
                </ajaxToolkit:ComboBox>
                <asp:SqlDataSource ID="SqlDataSource3" 
                    runat="server" ConnectionString="<%$ ConnectionStrings:cs %>" 
                    SelectCommand="SELECT distinct City FROM [StateMaster] where [State =@State]">
                    <SelectParameters>
                 <asp:ControlParameter ControlID="ComboBox1" Name="State" PropertyName="SelectedValue" Type="String" />
                                        </SelectParameters>
                </asp:SqlDataSource>
        </div>

    </div>
  
    
    </form>
Posted 8-Nov-17 3:56am
Updated 8-Nov-17 6:55am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Check the corrections

<div class="col-md-12">
        <ajaxToolkit:ComboBox ID="CmbCountry"  AppendDataBoundItems="True" AutoPostBack="true"
            runat="server" AutoCompleteMode="Suggest" DataSourceID="SqlDataSource1"
            DataTextField="Country" DataValueField="Country" MaxLength="0" Style="left: auto; top: auto;">
        </ajaxToolkit:ComboBox>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:cs %>"
            SelectCommand="SELECT distinct Country from [StateMaster]"></asp:SqlDataSource>
</div>
<div class="col-md-12">
        <ajaxToolkit:ComboBox ID="ComboBox1"
            AppendDataBoundItems="True" runat="server" AutoCompleteMode="Suggest"  AutoPostBack="true"
            DataSourceID="SqlDataSource2" DataTextField="State"
            DataValueField="State"
            MaxLength="0" Style="left: auto; top: auto;">
        </ajaxToolkit:ComboBox>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="<%$ ConnectionStrings:cs %>"
            SelectCommand="SELECT distinct State from [statemaster] where [Country]=@Country">
            <SelectParameters>
         <asp:ControlParameter ControlID="cmbCountry" Name="Country" PropertyName="SelectedValue" Type="String" DefaultValue="Country" />
                                </SelectParameters>
        </asp:SqlDataSource>

</div>
<div class="col-md-12">
        <ajaxToolkit:ComboBox ID="ComboBox2"  AppendDataBoundItems="True"  AutoPostBack="true"
            runat="server" AutoCompleteMode="Suggest"
            DataSourceID="SqlDataSource3" DataTextField="City"
            DataValueField="City" MaxLength="0" Style="left: auto; top: auto;">
        </ajaxToolkit:ComboBox>
        <asp:SqlDataSource ID="SqlDataSource3"
            runat="server" ConnectionString="<%$ ConnectionStrings:cs %>"
            SelectCommand="SELECT distinct City FROM [StateMaster] where [State] =@State">
            <SelectParameters>
         <asp:ControlParameter ControlID="ComboBox1" Name="State" PropertyName="SelectedValue" Type="String" />
                                </SelectParameters>
        </asp:SqlDataSource>
</div>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.181207.3 | Last Updated 8 Nov 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100