views:

103

answers:

1

I tried many things but I always get "cannot convert string to membershipuser"

from the ASP.Net MVC Membership Starter Kit

this line from file ListUsers.aspx

var users = (ViewData["Users"] as List<MembershipUser>);

ViewData["Users"] come from

 public virtual ViewResult Index( int? pageIndex, int? pageSize )
 {
  ViewData["Title"] = "Membership Administration";
  int totalRecords;
  var members = Membership.GetAllUsers( pageIndex ?? 0, pageSize ?? 25, out totalRecords );
  ViewData["Users"] = ToList<MembershipUser>( members );
  ViewData["Roles"] = dotNetRoles.GetAllRoles().ToList();
  return View( "ListUsers" );
 }

thanks!

+8  A: 
Dim users = TryCast(ViewData("Users"), List(Of MembershipUser))
Praveen Angyan
thanks, I was using ctype...
Fredou