在服务器端设置 CascadingDropDown 的父下拉列表
我有 2 个带有 CascadingDropDown 的 DropDownList 控件,
我需要将数据设置为服务器端的第一个下拉列表 如果我这样做,当我在客户端获取页面时,第一个没有数据的 DropDownList 我在服务器端设置的
感谢您的帮助
//client
<asp:DropDownList ID="ddlAjaxManufacturer" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDownManufacturer" runat="server"
TargetControlID="ddlAjaxManufacturer" Category="Make" PromptText="....." ServicePath="../../Ajax.asmx"
ServiceMethod="GetMakes" />
<asp:DropDownList BackColor="white" ID="ddlAjaxModel" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDownModel" runat="server" TargetControlID="ddlAjaxModel"
ParentControlID="ddlAjaxManufacturer" PromptText="....." ServiceMethod="GetModelsForMake"
ServicePath="../../Ajax.asmx" Category="Model" />
//server
ddlAjaxManufacturer.Items.Add(new ListItem("...", "", true));
ddlAjaxManufacturer.Items.Add(new ListItem("11", "ford", true));
ddlAjaxManufacturer.Items.Add(new ListItem("22", "bmw", true));
I have have 2 DropDownList controls with CascadingDropDown
I need set data to the first dropdownlist on server side
if i do this, and when i get page on client side, the first DropDownList without data
that i set on server side
Thanks for any help
//client
<asp:DropDownList ID="ddlAjaxManufacturer" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDownManufacturer" runat="server"
TargetControlID="ddlAjaxManufacturer" Category="Make" PromptText="....." ServicePath="../../Ajax.asmx"
ServiceMethod="GetMakes" />
<asp:DropDownList BackColor="white" ID="ddlAjaxModel" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDownModel" runat="server" TargetControlID="ddlAjaxModel"
ParentControlID="ddlAjaxManufacturer" PromptText="....." ServiceMethod="GetModelsForMake"
ServicePath="../../Ajax.asmx" Category="Model" />
//server
ddlAjaxManufacturer.Items.Add(new ListItem("...", "", true));
ddlAjaxManufacturer.Items.Add(new ListItem("11", "ford", true));
ddlAjaxManufacturer.Items.Add(new ListItem("22", "bmw", true));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试做的事情可能会起作用,但在不同的情况下。
您是否尝试过使用网络服务来填充您的下拉列表?据我所知 CascadingDropDown 与 Web 服务一起使用,以便使用 ajax 填充下拉按钮,您看过这个视频吗?
http:// /www.asp.net/ajax/videos/use-aspnet-ajax-cascading-drop-down-control-to-access-a-database
它显示了 CascadingDropDown 扩展程序的工作原理
What your trying to do may work but in a different scenario.
have you tried to use a web service to populate your dropdownlists? as far as i know CascadingDropDown works with a web service in order to populate the drop down buttons using ajax, did you see this video ?
http://www.asp.net/ajax/videos/use-aspnet-ajax-cascading-drop-down-control-to-access-a-database
it shows how CascadingDropDown extender works