vendredi 13 septembre 2019

How to submit multiple checkbox selections containing existing selections and update the new modified items in ASP.NET MVC

I have a model called Course and another model called SelectedCourse. These two models represent two different tables and have exclusive properties to their own and hence not the same type.

I would like to display List<Course> on my page in the form of multiple check-boxes. The courses that are available in the List<SelectedCourse> should be marked as checked.

How do I build my ViewModel to achieve this?

For Post, I would like to return the list of my ViewModel back to the controller and the POST action. And then be able to only delete/add the items that were modified (selected/un-selected) to the table representing List<SelectedCourse>.

How do I achieve this?

(Because I don't know how to create my ViewModel, I cannot provide cshtml or controller actions to prove effort)




Aucun commentaire:

Enregistrer un commentaire