Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:00:01+00:00 2026-05-28T16:00:01+00:00

For the past couple weeks I have been researching everything I possibly can and

  • 0

For the past couple weeks I have been researching everything I possibly can and have seemed to hit a wall on figuring out how to create a form using multiple models and saving to a database.

I am trying to be able to add 1 or more ingredients to a recipe on a single form create. I have created all the generated template crud views. I’m confused on which direction to go with this and am debating on looking into using MVC Controls Toolkit as well because I need the ability to add another ingredient on the form using jquery and ajax. Right now though, my main concern is just being able to bind the Recipe, Ingredient, and RecipeIngredient model if needed onto the form.

Any help will be greatly appreciated with setting up my view and controller methods! Thanks in advance 🙂

Here are my model classes, a viewmodel, the controller method.
Unfortuantly I dont have enough reputation to post a image but here is the link to my database diagram. http://i44.tinypic.com/xp1tog.jpg.
I hope this is enough detail but if more is needed please let me know.

    public ActionResult CreateFullRecipe()
    {
        var recipeViewModel = new RecipeViewModel();
        //Im getting a RecipeIngredients null error as well below..
        recipeViewModel.RecipeIngredients.Add(new RecipeIngredient());
        return View(recipeViewModel);
    }

public class Recipe
{
    public int RecipeID { get; set; }
    public string RecipeName { get; set; }
    public string Description { get; set; }
    public int? PrepTime { get; set; }
    public int? CookTime { get; set; }
    public string ImageURL { get; set; }

    public virtual ICollection<RecipeTag> RecipeTags { get; set; }
    public virtual ICollection<Rating> Ratings { get; set; }
    public virtual ICollection<RecipeStep> RecipeSteps { get; set; }
    public virtual ICollection<RecipeIngredient> RecipeIngredients { get; set; }

}

public class Ingredient
{

    public int IngredientID { get; set; }
    public string IngredientName { get; set; }

    public virtual ICollection<RecipeIngredient> RecipeIngredients { get; set; }
}

    public class RecipeIngredient
{
    public int RecipeIngredientID { get; set; }
    public string IngredientDesc { get; set; }
    public string Amount { get; set; }
    public int RecipeID { get; set; }
    public int? IngredientID { get; set; }

    public virtual Recipe Recipe { get; set; }
    public virtual Ingredient Ingredient { get; set; }
}

public class RecipeViewModel
{
    public Recipe Recipe { get; set; }
    public Ingredient Ingredient { get; set; }
    public ICollection<RecipeIngredient> RecipeIngredients { get; set; }
}

@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
    <legend>Recipe</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.Recipe.RecipeName)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Recipe.RecipeName)
        @Html.ValidationMessageFor(model => model.Recipe.RecipeName)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Ingredient.IngredientName)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Ingredient.IngredientName)
        @Html.ValidationMessageFor(model => model.Ingredient.IngredientName)
    </div>



    <ul>
    @foreach (var recipeingredient in Model.RecipeIngredients)
    {
        <li>
            @recipeingredient.Ingredient.IngredientName
       </li>
    }
    </ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:00:02+00:00Added an answer on May 28, 2026 at 4:00 pm

    You do not need any other toolkit/tool to be able to do it. You have all you need in MVC and JQuery. Below is a great article on model binding. It explains how to bind a list of classes too. I recommend reading the whole thing. If it was me, I would start simple, just bind one of the classes, then add a view model, then a collection of classes/entities

    Model Binding

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been developing a site for the past couple of days and have everything
I've been learning html and css for the past couple weeks. Now I have
for that past couple of weeks I have been creating generic script that is
I have been running an MSDEPLOY command successfully for the past couple weeks until
I have been experimenting with methods over the past couple of weeks trying to
I've been playing with Objective-C the past couple of weeks and have a working
I have been learning Scala for the past couple of months and now I
There have been a couple of threads on this topic in the past that
I have noticed the past couple of weeks that every once in awhile my
I have just started using jQuery in the past couple of weeks and am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.