我正在尝试构建一个类似于
的视图对于我这样添加的模型
public class UsrViewModel
{
public IEnumerable<User> SysUser { get; set; }
}
Public class User
{
public int ID {get; set:}
public bool isActive {get; set:}
public string user {get; set:}
public string location {get; set:}
public string usertype {get; set:}
public string Type {get; set:}
public int UserOrder {get; set:}
public bool isVisible {get; set:}
}
然后我创建了如下所示的视图,但在这里我得到了以下错误
@model ProjectName.ViewModels.UsrViewModel
@{
}
<div class="content-page">
<div class="content">
<div class="container">
<div class="row">
<div class="col-xs-12">
@using (Html.BeginForm("Users", "Sample", FormMethod.Post))
{
<table class="table table-striped table-bordered" id="SysUser ">
<tr>
...
</tr>
@if (Model != null)
{
for (int i = 0; i < Model.SysUser.Count; i++)
{
<tr>
<td>
[i]
</td>
....
</tr>
}
}
</table>
</div>
<div class="col-sm-offset-1 col-sm-11">
<button type="submit" class="btn btn-purple waves-effect waves-light btn-wd-130">Save</button>
<button type="submit" class="btn btn-default waves-effect waves-light btn-wd-130">Clear</button>
</div>
}
</div>
<!-- end row -->
</div>
</div>
</div>
</div>
运营商&#39;&lt;&#39;不能应用于&#39; int&#39;类型的操作数和&#39;方法 组&#39;
在此行for (int i = 0; i < Model.SysUser.Count; i++)
答案 0 :(得分:1)
尝试:
for (int i = 0; i < Model.SysUser.Count(); i++)
答案 1 :(得分:0)
您是否尝试使用 ForEach()代替 For()?像这样:
ForEach(var thisUser from Model.SysUser){
<tr>
<td>
@thisUser.ID
</td>
....
</tr>
}