在我的案例中,使用Country,State,City和MainRoad的级联下拉列表。
它在选择上工作正常,但我希望当国家/地区项目更改onkeyup或onkeydown时,加载依赖状态项目对州,城市或MainRoad相同。
如何做到这一点请提供完整的解决方案。
我的代码是:
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc1:ToolkitScriptManager><div><table cellpadding="3" cellspacing="3"><tr><td>Country</td><td><asp:DropDownList ID="dr_country" runat="server" ></asp:DropDownList><cc1:CascadingDropDown ID="cas_country" runat="server"Category="Country" TargetControlID="dr_country" UseContextKey="true" LoadingText="Loading ......" PromptText="Select Country" PromptValue="" ServiceMethod="BindCountrydropdown" ServicePath="CascadeDropDownService.asmx"> </cc1:CascadingDropDown></td></tr>
<tr><td>State</td><td><asp:DropDownList ID="dr_state" runat="server"></asp:DropDownList><cc1:CascadingDropDown ID="cas_state" runat="server" Category="State" TargetControlID="dr_State" ParentControlID="dr_country" LoadingText="Loading ......" PromptText="Select State" PromptValue="" ServiceMethod="BindStatedropdown" ServicePath="CascadeDropDownService.asmx"></cc1:CascadingDropDown></td></tr><tr><td>City</td><td><asp:DropDownList ID="dr_city" runat="server" ></asp:DropDownList><cc1:CascadingDropDown ID="cas_city" runat="server" Category="Region" TargetControlID="dr_city" ParentControlID="dr_State" PromptValue="" LoadingText="Loading Cities..." PromptText="Select City" ServiceMethod="BindCitydropdown" ServicePath="CascadeDropDownService.asmx"> </cc1:CascadingDropDown>
</td></tr><tr><td>MainRoad</td><td><asp:DropDownList ID="dr_mainroad" runat="server"></asp:DropDownList><cc1:CascadingDropDown ID="cas_mainroad" runat="server" Category="Mainroad" TargetControlID="dr_MainRoad" ParentControlID="dr_city" PromptValue="" LoadingText="Loading Main Road..." PromptText="Select Mainroad" ServiceMethod="BindMainroadropdown" ServicePath="CascadeDropDownService.asmx"></cc1:CascadingDropDown></td></tr></table></div>
答案 0 :(得分:0)
您可以在不使用ajax的情况下轻松完成此操作。只需绑定dr_state
<{1}} selecedindexchange
事件中的dr_country
即可
<asp:DropDownList ID="dr_country" CssClass="form-control" runat="server"
AutoPostBack="True" onselectedindexchanged="dr_country_SelectedIndexChanged">
并在代码中
protected void dr_country_SelectedIndexChanged(object sender, EventArgs e)
{
// Bind you dr_state dynamically here with parameter country.
}
和城市和街道地址相同。