简体   繁体   English

从列表框1中的选择标记列表框2中的项目

[英]Mark items in Listbox 2 from selection in ListBox 1

I have two ListBox with some items in each. 我有两个ListBox,每个都有一些项目。 I have three tables, lets say, company, employee, company_employee 我有三个表,可以说是公司,员工,company_employee

I populate the first ListBox with the company, second ListBox with employee. 我用公司填充第一个ListBox,用员工填充第二个ListBox。 What I want is to select a company and when I do that, select what employee's that are connected to that company. 我想要的是选择一家公司,然后选择要与该公司建立联系的员工。

How can I do this with asp.net MVC 4? 如何使用asp.net MVC 4做到这一点? I thought of a ajax-solution to get the records in company_employee depending on my first listbox selection id, but im not sure how to do this with asp.net. 我想到了一个ajax解决方案,该方法取决于我的第一个列表框选择ID,以获得company_employee中的记录,但是我不确定如何使用asp.net进行此操作。

Any suggestions to lead me forward? 有什么建议可以引导我前进吗?

Best regards, 最好的祝福,

me. 我。

Use a jquery event triggered on a change of your first listbox that calls a webservice that will return a custom collection(employees) of type employee, this method will take in the country id perhaps . 使用在第一个列表框发生更改时触发的jQuery事件,该事件调用一个将返回一个类型为employee的自定义集合(雇员)的Web服务,此方法可能会使用国家/地区ID。 Bind that collection to a control. 将该集合绑定到控件。 If you're expecting it all on a plate sorry but that is the way forward you can break this down and learn how to do each step. 如果您对所有这些都感到遗憾,但这是前进的道路,那么您可以分解并学习如何执行每个步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM