TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
manoj singh
1.6k
142
9.7k
How To Edit Nested List in Mvc
Aug 17 2018 5:01 AM
Problem - List binding gets null
My View
@model List<WebApplication5.Models.Site>
@{
ViewBag.Title =
"Home Page"
;
int
i = 0;
int
j = 0;
}
@
using
(Html.BeginForm(
"Index"
,
"Home"
, FormMethod.Post))
{
<table
class
=
"table"
>
@foreach (var item in Model)
{
<tr>
<td>
@Html.Hidden(
"ItemSiteCosting.Index"
, (@i + 10))
@Html.TextBox(
"ItemSiteCosting["
+ (@i + 10) +
"].name"
, Model[i].name)
@item.name
</td>
<td>
<table
class
=
"table"
>
@{ j = 0;}
@foreach (var item2 in item.xyz.costing.Sitecosting)
{
<tr>
<td>
@Html.TextBox(
"ItemSiteCosting["
+ (@i + 10) +
"].xyz.costing.Sitecosting["
+ (@j + 10) +
"].Amount"
, Model[i].xyz.costing.Sitecosting[j].Amount)
@item2.Amount
</td>
</tr>
j = j + 1;
}
</table>
</td>
</tr>
i = i + 1;
}
</table>
<input type=
"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<Money>();
}
public
string Name { get; set; }
public
List<Money> Sitecosting {get;set;}
}
public
class
Money
{
public
decimal? Amount { get; set; }
}
Reply
Answers (
1
)
conversion issue
Unable to make the session state request to the session stat