Hi @Kmcnet, I change the code according to your previous question to fit your new requirement, Hoping it can give you some help.
Model
public class ReviewOfSystemsVM
{
public string? EnteredBy { get; set; }
public List<tbl_Log_ReviewOfSystems>? tbl_Log_ReviewOfSystems { get; set; } = new List<tbl_Log_ReviewOfSystems>() { };
}
Controller
public class SystemReviewController : Controller
{
public IActionResult Index()
{
ReviewOfSystemsVM reviewOfSystemsVM = new ReviewOfSystemsVM();
reviewOfSystemsVM.tbl_Log_ReviewOfSystems = PopulateList();
return View(reviewOfSystemsVM);
}
[HttpPost]
public IActionResult InsertReviewOfSystems(ReviewOfSystemsVM model)
{
return Ok(model);
}
private List<tbl_Log_ReviewOfSystems> PopulateList()
{
return new List<tbl_Log_ReviewOfSystems>() {
new tbl_Log_ReviewOfSystems()
{
ClientID = 1,
VisitID= 9999999,
MRNumber= 5396,
QuestionID= 8112,
CategoryCode= 1,
Category= "General",
EnglishDescription= "BMI",
QuestionResponse= "None",
DateEntered= DateTime.Now,
},
new tbl_Log_ReviewOfSystems()
{
ClientID = 1,
VisitID= 9999999,
MRNumber= 5396,
QuestionID= 2092,
CategoryCode= 1,
Category= "General",
EnglishDescription= "BODYACHES",
QuestionResponse= "None",
DateEntered= DateTime.Now,
}
};
}
}
View
@model ReviewOfSystemsVM
<h1>Index</h1>
<form method="post" action="/SystemReview/InsertReviewOfSystems">
<div>
@Html.LabelFor(Model=>Model.EnteredBy)
@Html.TextBoxFor(Model=>Model.EnteredBy)
</div>
<table class="table">
<thead>
<tr>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].ClientID)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].VisitID)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].MRNumber)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].QuestionID)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].CategoryCode)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].Category)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].EnglishDescription)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].QuestionResponse)
</th>
<th>
@Html.LabelFor(model => Model.tbl_Log_ReviewOfSystems[0].DateEntered)
</th>
<th></th>
</tr>
</thead>
<tbody>
@for (var i = 0; i < Model.tbl_Log_ReviewOfSystems.Count; i++)
{
<tr>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].ClientID)
</td>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].VisitID)
</td>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].MRNumber)
</td>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].QuestionID)
</td>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].CategoryCode)
</td>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].Category)
</td>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].EnglishDescription)
</td>
<td>
@Html.TextBoxFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].QuestionResponse)
</td>
<td>
@Html.DisplayFor(modelItem => Model.tbl_Log_ReviewOfSystems[i].DateEntered)
</td>
</tr>
}
</tbody>
</table>
<div>
<input type="submit" value="submit" />
</div>
</form>
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Xinran Shen