I am developing my first ASP.Net MVC 3 web application against a SQL Server Database. I used Database First to create the dbContext and Models from an existing database.
I am trying to create a master/detail view of 1-M relationships. I have TableA which is related to TableB and TableC each with a 1-M relationship. but TableB and TableC are not directly related to each other.
When the user goes to the Details view of a record from TableA, I would like it to show a section at the top of the view with data from the columns within TableA. Then below I would like to have a group of tabs with one tab for each related table (TableB and TableC). When the user clicks on the TableB tab for example, I would like to load a partial view listing all the related records in TableB.
Can someone help me figure out how accomplish this? I would post code, but I’m not really sure where to begin.
I have done some research and found a lot of posts discussing ViewModels, but I’m not sure how this would differ from my TableA Model, which includes the related collections for TableB and TableC. I also have discovered how to load the records from each relationship into different tables within the TableA Details view, but this does not include the tabbing functionality I need.
Thanks in advance.
I ended up creating partial views for each child table and using an AJAX ActionLink to load the partial view based on the tabs.
Part of TableA view (Master):
TableB Controller: