I have a model class. Inside that, I have a class and a list which is that type.
public class ItemSetupModel
{
public class UPC
{
public int ItemNumberForUPC { get; set; }
public string GCOwner { get; set; }
public string GCFeeItem { get; set; }
public string GCBranded { get; set; }
public string query { get; set; }
}
public List<UPC> lstUPC { get; set; }
public UPC upc;
public ItemSetupModel()
{
this.upc = new UPC();
this.lstUPC = new List<UPC>();
this.lstUPC.Add(this.upc);
}
}
cshtml is as below :
@model PricingUpdates.Models.ItemSetupModel
@using (Html.BeginForm())
{
@for (int i = 0; i < Model.lstUPC.Count; i++)
{
@Html.Label("ItemNumberForUPC", "ItemNumber")
@Html.TextBoxFor(m => m.lstUPC[i].ItemNumberForUPC, new { @class = "form-control", Name = "UPCUpdate" + i })
}
}
Whenever I am posting the values, the action result model will never contain the values entered by me in the textbox. It will always show null
values for the list.