Nilesh Thorath Ответов: 1

Как передать параметр SQL-запроса с помощью ajaxtoolkit


У меня есть редактируемый ajaxtoolkit
он прекрасно работает с SQL запросом no parameter

Я хочу использовать параметр, который был вызван из другого элемента управления ajaxtoolkit

Мне нужно , чтобы вы помогли мне, как передать параметр в Ajax ?

Что я уже пробовал:

<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>

1 Ответов

Рейтинг:
11

Karthik_Mahalingam

Проверьте исправления

<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>