Computer Science, asked by prathampradhan115, 10 months ago

How to pass ilist object from get actionresult method as parameter in c# in post actionresult type method

Answers

Answered by hemanji2007
0

want to post a List of items to controller from Razor view , but i am getting a List of objects as null My class structre is

Model:

List<Subjects> modelItem

class Subjects

{

int SubId{get;set;}

string Name{get;set;}

List<Students> StudentEntires{get;set;}

}

class StudentEntires

{

int StudId{get;set;}

string Name{get;set;}

int Mark{get;set;}

}

The model itself is a list of items and every items contain List of child items as well. Example model is a list of Subjects and every subject contains a List of Students, and i want to input mark for every student

My View is like

@model IList<Subjects>

@{

Layout = "~/Views/Shared/_Layout.cshtml";

}

@using (Html.BeginForm())

{

@Html.ValidationSummary(true)

if (Model.Count > 0)

{

@for (int item = 0; item < Model.Count(); item++)

{

<b>@Model[item].Name</b><br />

@foreach (StudentEntires markItem in Model[item].StudentEntires)

{

@Html.TextBoxFor(modelItem => markItem.Mark)

}

}

Please mark as brainliest answer PL plz

Similar questions