I have something similar, the product belongs to many categories and categories, it has many products.
In my administrative view to create new products, I can allow the user to select mutliple "tags" for the categories in which this product should be listed.
- - auto ajax jQuery, TagIt.
public class HomeController : Controller
{
public ActionResult Create()
{
var tags = new List<Tag>()
{
new Tag() { TagId = 1, Name = "Planes", Posts = new Collection<Post>() },
new Tag() { TagId = 2, Name = "Cars", Posts = new Collection<Post>() },
new Tag() { TagId = 2, Name = "Boats", Posts = new Collection<Post>() }
};
ViewBag.MultiSelectTags = new MultiSelectList(tags, "TagId", "Name");
return View();
}
[HttpPost]
public ActionResult Create(Post post, int[] tags)
{
return RedirectToAction("Create");
}
}
View/Create.cshtml
@model MvcApplication1.Models.Post
<h2>Create</h2>
@using (Html.BeginForm("Create", "Home", FormMethod.Post))
{
<label>Name</label>
@Html.TextBoxFor(model => model.Name)
<label>Tags For Post</label>
@Html.ListBox("Tags", (MultiSelectList)ViewBag.MultiSelectTags)
<input type="submit" value="Submit Post"/>
}
all :

, , , , html- ""
