0

I'm beginner to mvc. I have a form with check boxes, radio button and text boxes, with an action that insert data in Table1.

A part of the form is a list of checkbox with multiple selection that should be inserted in Table2.

How it can work? Can a form work with 2 action? or there is another way to save data in 2 or more table?

diana
  • 11
  • 3
  • A form works with a model - you can create a view model to represent whatever you want in the view - refer [What is ViewModel in MVC?](https://stackoverflow.com/questions/11064316/what-is-viewmodel-in-mvc) –  Aug 11 '18 at 09:18
  • I created 2 model. One for save data in table1 and one for save data in table 2. but how about insert actions? where should I write the insertTable1?where the insertTable2? – diana Aug 11 '18 at 09:23
  • Read my comment again, and the link! –  Aug 11 '18 at 09:23
  • Your action can contain code that persists data in both tables. The code varies depending on the data access technology you are using (ADO, LinqToSQL, Entity Framework, e.t.c) but in any case all you have to do is issue two insert queries to the database. – dpant Aug 11 '18 at 10:58
  • Thank you dpant . Two insert queries in two action? I use Entity Framework. – diana Aug 12 '18 at 05:16

0 Answers0