This is my model:
public class RegistryItemModel
{
public string uuid { get; set; }
public int version { get; set; }
public string form { get; set; }
public int formVersion { get; set; }
public string modified { get; set; }
public string nodeUUID { get; set; }
public List<RegistryItemValue> data { get; set; }
}
I only need to update data prop. Here's the class:
public class RegistryItemValue
{
public string id { get; set; }
public string type { get; set; }
public string label { get; set; }
public string value { get; set; }
public string key { get; set; }
public string valueID { get; set; }
}
And then there's the view:
<html>
<head>
<title>@ViewBag.Title</title>
</head>
<body>
@model SWG_ArtaAPI.Models.RegistryItemModel
@using (Html.BeginForm("Save", "RegistryItem", FormMethod.Post))
{
<div class="form-group">
<h3>@ViewBag.Title</h3>
<table border="0">
@for (var i = 0; i < Model.data.Count; i++)
{
<tr>
@if (@Model.data[i].label != null)
{
<td><label>@Model.data[i].label</label></td>
}
@switch (@Model.data[i].type)
{
case "textbox":
<td>@Html.TextBoxFor(m => m.data[i].value)</td>
break;
}
</tr>
}
</table>
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Отправить" class="btn btn-default" />
</div>
</div>
}
</body>
</html>
The view displays my data just fine, I get values in input fields and can change them. But when I try to save it (submit) in my post method, I get my model class with all props set to null. Here's how it's defined:
[HttpPost]
public string Save(RegistryItemModel model)
What is wrong with my code? Why I'm always getting null? Here's how it looks