Crate a view model which contains properties as per the data you fetch from the table.
Create one view model to bind the data in view.
Public Class YourViewModel
{
Public string Prop1 {get;set;}
Public string Prop2 {get;set;}
Public string Prop3 {get;set;}
Public string Prop4 {get;set;}
}
Controller
---------------
Public ActionResult()
{
YourViewModel modl= new YourViewModel();
''' Yoor logic to bind the data into this model form DB.
return view ("YourViewName", Model);
}
View
---------
@model List<yourviewmodel>
@foreach(var item in Model)
{
}
Prop1 | Prop2 | Prop3 | Prop4 |
---|
@item.Prop1 | @item.Prop2 | @item.Prop3 | @item.Prop4 |