Это очень легко сделать с ASP.NET MVC. Сначала создайте класс Model, который содержит все свойства, которые вы хотите отобразить в html-таблице, как показано ниже.
public class UserModel
{
public List<User> Users { get; set; }
}
public class User
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string PostCode { get; set; }
public string Country { get; set; }
}
Затем создайте контроллер, как показано ниже:
public class UsersController : Controller
{
// GET: Users
public ActionResult Index()
{
var model = new UserModel();
model.Users = new List<User>();
// model.Users should be retrieved from t.std_users()
model.Users.Add(new Models.User
{
ID = 1,
FirstName = "James",
LastName = "Brown",
PostCode = "1111",
Country = "USA"
});
return View(model);
}
}
Наконец, создайте представление Index.cshtml в папке Views \ Users, как показано ниже:
@model MVC5.Models.UserModel
@{
ViewBag.Title = "Index";
}
<h2>User list</h2>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th width="100px" nowrap>ID</th>
<th width="200px" nowrap>First name</th>
<th width="200px" nowrap>Last name</th>
<th width="200px" nowrap>ZIP / Post code</th>
<th>Country</th>
</tr>
</thead>
<tbody>
@foreach (var user in Model.Users)
{
<tr class="odd gradeX">
<td>
@user.ID
</td>
<td>
@user.FirstName
</td>
<td>
@user.LastName
</td>
<td>
@user.PostCode
</td>
<td>@user.Country</td>
</tr>
}
</tbody>
</table>
Затем вы можете запустить ваше приложение и просмотреть html-страницу с http://localhost/Users.
Более подробное руководство по использованию ASP.NET MVC. Пожалуйста, посетите https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/introduction/getting-started.