开发者

Best way to pass across a list of parameters from one Controller to another

开发者 https://www.devze.com 2023-02-03 05:41 出处:网络
On my View I have a list of employees and a checkbox next to each one. The user selects 1 or more employ开发者_运维技巧ees and when he clicks submit, he navigates to the next page where he sees the de

On my View I have a list of employees and a checkbox next to each one. The user selects 1 or more employ开发者_运维技巧ees and when he clicks submit, he navigates to the next page where he sees the details of each employee selected. So I want to send a list of employee numbers from one controller to the next one. One way I can do this is to use a Session object. But is that the best way?


think of this instead of having a view sending parameters to another controller. in this case, from the employee list view to the details controller. change the form on the list view such that it sends the selected employee ids to a method on the details controller. in the details controller, you can query the database for whatever details you need for each of the given employee IDs


Instead of passing employees you could POST a list of selected employee ids to the details controller and then fetch the corresponding details from your repository.

0

精彩评论

暂无评论...
验证码 换一张
取 消