0

I think this may be a very simple question, but I am only just starting out with .net and c# at all, and only really just finally getting my head around OO stuff.

I have built the NerdDinner application, and I am building on top of it currently with my own project.

What I need to do, in the context of nerd dinner, is display the details of a dinner, but also show all the assoicated RSVP's on the same page.

The url could be the same as normal

dinners/details/2

but the 2 would be used to bring back all rsvp's related to that, and display them in a list on the same page.

I have spend some time trying to do this in the dinnerRepository.cs file, but I'm getting a bit stuck, and not sure the best way to do this.

I would then like to be able to add more rsvp's from that same page (I understand that dosent work in this example, but you seen that I am trying to Add more of rows to tableB, related to a single row in tableA)

Please only answer the first question if you feel the second part should be asked elsewhere.

Thanks so much for any help.

3 Answers 3

1

You do not need to change the dinnerRepository.cs file at all. The dinner model already has a RSVP collection. You will just need to modify the Details view as such:

    <p>
    <% foreach(NerdDinner.Models.RSVP rsvp in this.Model.RSVPs)
       { %>
       <%= Html.Encode(rsvp.AttendeeName) %>
       <br />
       <%} %>
    </p>

Your done.

Sign up to request clarification or add additional context in comments.

Comments

0

IIRC, the details view is passed an instance of Dinner. Simply render out the RSVPs for that dinner on the details page.

1 Comment

So are you saying I don't have to do anything to the model, it should already be there?
0

I like using RenderAction for this kind of thing. RenderAction allows you to target a specific subcontroller method to render a subview in the page. Since it is a modular technique, it can be used in more than one page without changes.

RenderAction is part of the Futures assembly: Microsoft.Web.Mvc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.