下拉列表中的国家明智城市 [英] country wise city in dropdown list
本文介绍了下拉列表中的国家明智城市的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按国家显示城市..
表示当我更改国家/地区时,然后在该城市的下拉列表中显示该国家/地区中的城市...
那我该怎么办??
请帮我..
i want to display city according to country..
means when i change country then in city dropdown display cities which is in that country...
so how can i do???
plz help me..
thanks in advance.
推荐答案
您可以使用AjaxControlToolkit的CascadingDropDown Extender来满足您的要求
请在波纹管链接上查看
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx
You can use CascadingDropDown Extender of AjaxControlToolkit to achieve your requirement
Please view on the bellow link
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx
下拉列表上有一个名为 ^ ]在控件上选择一个值时将触发.该国家/地区"控件的事件应该存在于您的代码中,因为这是您将逻辑从数据库中检索城市的地方.我假设您在城市"表上具有该国家/地区的外键,因此检索非常简单.另外,您需要在控件的HTML/ASP.Net标记上将Autopostback设置为true,以便触发该事件.
There''s an event on the dropdownlist called SelectedIndexChanged[^] which fires up when a value has been selected on the control. That event for your Countries control should be existing on your code behind as that is where you will put the logic for retrieving the cities from your database. I assume you have a foreign key of the country on your Cities table so the retrieval is pretty straightforward. Also, you need to set Autopostback to true on the HTML/ASP.Net tag of your control so that the event will be fired.
这篇关于下拉列表中的国家明智城市的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文