Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. @Html.ActionLink("Add Related Data","Add",new { @id=364})
  2.  
  3. public class ChildDetails
  4. {
  5. public int ID { set;get;}
  6. public string Note { set;get;}
  7. public int ParentID { set;get;}
  8. public string ParentName { set;get;}
  9. }
  10.  
  11. public ActionResult Add(int id)
  12. {
  13. var parent=yourRepositary.Get(id);
  14. ChildDetails childViewModel=new ChildDetails();
  15. childViewModel.ParentID=id;
  16. childViewModel.Name=parent.Name;
  17. return View(childViewModel);
  18. }
  19.  
  20. @model ChildDetails
  21.  
  22. <h2>@Model.ParentName</h2>
  23. @using(Html.BeginForm())
  24. {
  25. @Html.TextBoxFor(x=>x.Note)
  26. @Html.HiddenFor(x=>x.ParentId)
  27. <input type="submit" />
  28. }
  29.  
  30. ViewBag.MyParam = "1";
  31.  
  32. ViewData("MyParam") = "1";
  33.  
  34. TempData("MyParam") = "1";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement