i have a data which i Deserialize and its save in viewbag. here is the model jsonroot and then the formatted data in datalist model now i want to display the Property, oldValue on view how can i do this
i tried using this
@foreach (var item in ViewBag.DataList)
{
@item.Property
}
but it give error of RuntimeBinderException: 'SmartAdmin.WebUI.Models.JsonRoot' does not contain a definition for 'Property'
CodePudding user response:
The ViewBag.DataList
is a nested array.
You have to iterate the first level/root array and iterate the inner array which is FormattedData
property.
@foreach (var jsonRoot in ViewBag.DataList)
{
@foreach (var data in jsonRoot.FormattedData)
{
@data.Property
}
}