0

When I go to Create view I pass name, for one text.

public ActionResult AddItem(int id, string name)
{
    ViewBag.Name = name;

    return View();
}

I passed name to new View:

@Html.ActionLink("add", "AddItem", "Items", new { id = item.ItemID, name = item.Name }, null)

I want to use item.Name for one text, but I see it here:

@Html.EditorFor(model => model.Name)

What I do wrong? I don't understand how this name applied to new item???

user1711993
  • 271
  • 4
  • 20
  • 2
    You setting a `ViewBag` property, not the model property. –  Oct 12 '14 at 21:11
  • If I delete this name = item.Name from new { id = item.ItemID, name = item.Name }. Everything ok!! ViewBag.Name = name; if I delete this, nothing changes I see pass data – user1711993 Oct 12 '14 at 21:14
  • See http://stackoverflow.com/questions/4375323/binding-conflict-between-a-property-named-title-in-my-model-and-view-title-in-my and http://stackoverflow.com/questions/5103889/asp-net-mvc-3-model-binding-viewbag-title-clash-with-input-of-id-title – Rhumborl Oct 12 '14 at 21:15

0 Answers0