Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am currently learning MVC 3.0 and have performed basic tasks insert, update etc on on table. Now I was to display my data from multiple tables ( Order and OrderDetail) in one view and also want to insert data in two tables from one view. Please guide me how can I do this? Please don't refer to MVC tutorial link just guide me if you grap up the idea?
Posted

Simply, you need to select your data with a SQL statement that joins the two tables and gets the data you need. You can also insert data in to as many tables as you want, if you write your own SQL to do it.
 
Share this answer
 
Comments
touseef4pk 13-Jul-11 4:54am    
very poor answer...Please read my post thoroughly
By using sql server joins you can easy get data from different tables and if you want to insert data in different table you can use the poco class concept for different fields data to insert in different tables.


Thanks
Saurav Sharma
 
Share this answer
 
Comments
touseef4pk 15-Jul-11 0:32am    
How Can i do this in MVC? What my model should pass to the View?
You need to create a ViewModel in which you make instance of both tables and while creating a view refer the view model instead of model.
you can access both tables using the VM.

-Sagar Solanki
 
Share this answer
 
Comments
Member 14552976 31-Aug-19 7:43am    
can you give such example?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900