Problem - List binding gets null
My View
- @model List
- @{
- ViewBag.Title = "Home Page";
- int i = 0;
- int j = 0;
- }
- @using (Html.BeginForm("Index", "Home", FormMethod.Post))
- {
-
class="table">
- @foreach (var item in Model)
- {
- @Html.Hidden("ItemSiteCosting.Index", (@i + 10))
- @Html.TextBox("ItemSiteCosting[" + (@i + 10) + "].name", Model[i].name)
- @item.name
class="table">
- @{ j = 0;}
- @foreach (var item2 in item.xyz.costing.Sitecosting)
- {
- @Html.TextBox("ItemSiteCosting[" + (@i + 10) + "].xyz.costing.Sitecosting[" + (@j + 10) + "].Amount", Model[i].xyz.costing.Sitecosting[j].Amount)
- @item2.Amount
- j = j + 1;
- }
- i = i + 1;
- }
- "submit" value="Submit" />
- }
My models
- public class Site
- {
- public string name { get; set; }
- public BestPO xyz { get; set; }
- }
- public class BestPO
- {
- public BestPO()
- {
- costing = new SiteCost();
- }
- public string Cost { get; set; }
- public SiteCost costing { get; set; }
- }
- public class SiteCost
- {
- public SiteCost()
- {
- Sitecosting = new List
(); - }
- public string Name { get; set; }
- public List
Sitecosting {get;set;} - }
- public class Money
- {
- public decimal? Amount { get; set; }
- }
Mohammad SbeehPosted Sep 3, 2018, 12:30 AM
Index