且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

级联DROPDOWNLIST与MVC5,阿贾克斯,C#和MSSQL服务器

更新时间:2023-02-25 16:54:40

您已经得到了你的观点是强类型的一个模型。所有你需要做的是,在添加下拉列表(有关详细信息,请参见下面简称链接)更改事件。在变化的情况下,您可以加载值按选定的值,例如如果贝瑞被选中,您将需要获取相应的值贝瑞即葡萄,鳄梨。

You have already got a Model that your view is strongly typed with. All you need to do is, add a change event on dropdown list (for more information see referred link below). On change event, you can load the values as per selected value e.g. if Berry is selected you will need to fetch corresponding values for Berry i.e Grape, Avocado.

您可以加载使用JavaScript,当你有大量的数据是有用的值。或者你也可以preLOAD认为所有的数据,并在这种情况下,你只需要根据界面上的选择问题进行过滤的答案。

You can load values using JavaScript which is useful when you have large set of data. Or you can preload the view with all the data and in that case, you just need to filter the answers based on question selected on UI.

有关如何在实践中实现这一点帮助,请参阅层叠的DropDownList在MVC 4 。您可以根据您的需要类似的例子。

For help on how to achieve this in practice please refer Cascading DropDownList In MVC 4. You can find similar example based on your needs.