Reputation: 2313
I'm trying to build a view like following
For Model I added like this
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:}
}
then i created view like below, but here I'm getting Following error
@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>
Operator '<' cannot be applied to operands of type 'int' and 'method group'
in this line for (int i = 0; i < Model.SysUser.Count; i++)
Upvotes: 1
Views: 2971
Reputation: 157
Have you tried to use ForEach() instead For()? Like this:
ForEach(var thisUser from Model.SysUser){
<tr>
<td>
@thisUser.ID
</td>
....
</tr>
}
Upvotes: 0