开发者

Adding WebGrid to a MembershipUserCollection

开发者 https://www.devze.com 2023-02-08 18:14 出处:网络
Here\'s the snippet of my view that is giving me error @model MembershipUserCollection @{ ViewBag.Title = \"Index\";

Here's the snippet of my view that is giving me error

@model MembershipUserCollection
@{
    ViewBag.Title = "Index";
}

@{var usersGrid = new WebGrid(source: Model, rowsPerPage: 40);}

apparently 开发者_开发知识库the WebGrid constructor does not accept a MembershipUserCollection as a parameter. How can I get around this?

please help. I need to add pagination to the list of Users.


This should work:

@{var usersGrid = new WebGrid(source: Model.Cast<MembershipUser>(), rowsPerPage: 40);}

MembershipUserCollection implements the non-generic interface IEnumerable, whereas the WebGrid constructor parameter source is a generic IEnumerable<T>. To convert from IEnumerable to IEnumerable<T>, use the Cast extension method on IEnumerable.

0

精彩评论

暂无评论...
验证码 换一张
取 消