I need to include value from object which comes from controller via ViewBag inside the <label> and <input> html tag. The following is which I used inside the view page:
foreach (var stockItem in ViewBag.joinqry2)
{
<div class="col-md-2">
<label style='font-weight:normal;' name='InstockID' value= 'stockItem.ItemName' ><span> @(stockItem.ItemName) </span></label>
<input class='form-control input_field stockItem' name='labOrder.ConsumedInventories[ + i + ].ConsumedQuantity' type='number' id='" + data[i].Instock + "' min='0' value= '"+ stockItem.ConsumedQuantity + "'/>
</div>
}
ViewBag.joinqry2:
{ ConsumedQuantity = 1, ItemName = "Streck Tube" }
{ ConsumedQuantity = 1, ItemName = "Bubble Wrap" }
{ ConsumedQuantity = 7000, ItemName = "Biohazard Bag" }
{ ConsumedQuantity = 1, ItemName = "Absorbent Papers" }
{ ConsumedQuantity = 1, ItemName = "Test Tube" }
StockItem contains ConsumedQuantity and ItemName values inside the foreach loop but I am still getting error like this below:
My error is:
An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in App_Web_euru3gao.dll but was not handled in user code
Additional information: 'object' does not contain a definition for 'ItemName'
ConsumedQuantityandItemName?