Я хочу построить два столбца, первый столбец должен содержать элементы FirstList
, второй столбец должен содержать элементы SecondList
. Почему в моей реализации он помещает одну колонку под другую? Как это исправить? Мне нужен CSS-стиль uss вместо html?ASP.NET mvc html столбцы, отображающие
контроллер и классы:
namespace MvcApplication4.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
List<Employee> emp1 = new List<Employee>();
emp1.Add(new Employee { Number="1",Text="dfsfdsfsafdsafdasfadsf"});
emp1.Add(new Employee { Number = "2", Text = "asdfsa" });
emp1.Add(new Employee { Number = "3", Text = "dfsfdsfdasfsafdsafdasfdsafsaadsf" });
List<Employee> emp2 = new List<Employee>();
emp2.Add(new Employee { Number = "1", Text = "dfsfdsfsafdsafdasfadsf" });
emp2.Add(new Employee { Number = "2", Text = "asdfsa" });
emp2.Add(new Employee { Number = "3", Text = "dfsfdsfdasfsafdsafdasfdsafsaadsf" });
emp2.Add(new Employee { Number = "4", Text = "asdfsa" });
emp2.Add(new Employee { Number = "5", Text = "dfsfdsfdasfsafdsafdasfdsafsaadsf" });
return View(new IndexViewModel { FirstList = emp1, SecondList = emp2 });
}
}
public class IndexViewModel
{
public IEnumerable<Employee> FirstList { get; set; }
public IEnumerable<Employee> SecondList { get; set; }
}
public class Employee
{
public string Text { get; set; }
public string Number { get; set; }
}
}
Index.cshtml
@model MvcApplication4.Controllers.IndexViewModel
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<table>
<tbody>
@foreach (var item in Model.FirstList)
{
<tr>
<td>@item.Number</td>
<td>@item.Text</td>
</tr>
}
@foreach (var item in Model.SecondList)
{
<tr>
<td>@item.Number</td>
<td>@item.Text</td>
</tr>
}
</tbody>
</table>