So if you have your data in List<MyObject> you can either pass it directly to the view or pass it as part of a view model (depends if you need other data in the view too - I would always recommend a view model).
If you use a view model, create it like this:
public class MyViewModel
{
public List<MyObject> Items { get; set; }
}
in your controller:
List<MyObject> items = ...
MyViewModel vm = new MyViewModel()
{
Items = items
};
return View("MyView", vm);
In your view or partial view:
@inherits UmbracoViewPage<MyViewModel>
@foreach (var item in Model.Items)
{
<p>@item....</p>
}
So, is this what you are looking for or do you have any additional questions?
How to display json string as list Of record in screen
I use httpclient in controller to get the data from server. I manage to deserized it to list of object.
What I want to do is display the data like a data list or data grid in screen. Any recommendations?
Where do you want to display it? In the frontend? In the backoffice?
in the frontend. i means show it in umbraco web page.
thanks.
So if you have your data in
List<MyObject>
you can either pass it directly to the view or pass it as part of a view model (depends if you need other data in the view too - I would always recommend a view model).If you use a view model, create it like this:
in your controller:
In your view or partial view:
So, is this what you are looking for or do you have any additional questions?
is working on a reply...