Hi satabeach,
Please refer below sample.
Note: For this sample i have used temporary DataTable. For more details refer How to create Temporary Table in ASP.Net using C# and VB.Net.
Model
Public Class CustomersModel
Private _id As String
Public Property CustomerId() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Private _country As String
Public Property Country() As String
Get
Return _country
End Get
Set(ByVal value As String)
_country = value
End Set
End Property
End Class
Colntroller
Public Class HomeController
Inherits Controller
' GET: Home
Function Index() As ActionResult
Dim dt As DataTable = New DataTable
dt.Columns.AddRange(New DataColumn() {
New DataColumn("Id", GetType(Int32)),
New DataColumn("Name", GetType(String)),
New DataColumn("Country", GetType(String))})
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
Dim customers As List(Of CustomersModel) = New List(Of CustomersModel)
For Each row As DataRow In dt.Rows
Dim customer As CustomersModel = New CustomersModel With {
.CustomerId = Convert.ToInt32(row("Id")),
.Name = row("Name"),
.Country = row("Country")}
customers.Add(customer)
Next
Return View(customers)
End Function
End Class
View
@ModelType IEnumerable(Of model_declaration_in_view.CustomersModel)
@Code
Layout = Nothing
End Code
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<table class="table">
<tr>
<th>Id</th>
<th>Name</th>
<th>Country</th>
</tr>
@For Each item In Model
@<tr>
<td>@item.CustomerId</td>
<td>@item.Name</td>
<td>@item.Country</td>
</tr>
Next
</table>
</body>
</html>
Screenshot