I have a page to display every log (message, time, type, customerId, Name) in a html table. Since the log is huge I am using a IPagedList in the Razor MVC and this
Create a view model with the properties you need in the view
public class LogModelVM
{
public int SelectedCustomer { get; set; }
public IEnumerable<SelectListItem> CustomerList { get; set; } // suggested name change
public string Message { get; set; } // for the message search box?
public IPagedList<NowasteWebPortalMVC.Models.LogModel> Logs { get; set; }
.... // add properties for sortorder etc
}
Then in the controller method, initiaize a new LogModelVM
and assign the values (e.g. model.Logs = logs;
), and return the view model so that in the view you can use
@model yourAssembly.LogModelVM
....
@Html.DropDownListFor(m => m.SelectedCustomer, Model.CustomerList) // why change the id attribute?
....
@Html.PagedListPager(Model.Logs, page => Url.Action(...`
You should also consider adding the other properties such as sortOrder
and currentfilter
rather than using ViewBag
Side note: Ensure that all associated views, including the main view also use @model yourAssembly.LogModelVM