Matteo Pietro Peru
Matteo Pietro Peru

Reputation: 576

How to count element of one controller into another

i've a question to ask for my mvc project... i have two controllers: Giurisprudenza e GiurisprudenzaNode, these controllers implement an index with the list of elements and a crud system to add/edit/remove elements. In the Girusiprudenza view page every element has a button that return you into the relative GiurisprudenzaNode page, with the list of elements contained into the primary element. I would like to insert a label next to every element of the list in Giurisprudenza that say how many elements there are into that single primary element, but i don't know how to do that count... Anybody can help me?

Upvotes: 0

Views: 31

Answers (1)

rahul tiwari
rahul tiwari

Reputation: 47

for this you dont need two controllers or two different view . For this you need to follow below steps.

  1. Create a viewModel (Customize mix of both models)
  2. add custom property in you this viewmodel for counts
  3. create new view for this ViewModel class .

Let me know if you need code snippet for this. View Model from MSDN

Upvotes: 1

Related Questions