Controller
Function Index() As ActionResult
Dim dt As New DataTable
dt.Columns.Add("Name")
dt.Columns.Add("Age")
Dim dr As DataRow
dr = dt.NewRow()
dr("Name") = "Aaron"
dr("Age") = 19
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("Name") = "Justin"
dr("Age") = 19
dt.Rows.Add(dr)
Return View(dt)
End Function
View
@Code
ViewData("Title") = "MyTest"
Layout = "~/Views/Shared/_Layout.vbhtml"
Dim dt As Data.DataTable = Model
End Code
<table>
<tr>
@For Each row As System.Data.DataRow In dt.Rows
@<td>
<th>@row(0)</th>
</td>
Next
</tr>
</table>
沒有留言:
張貼留言