我正在尝试获取 userName 和 userID FromMembership.GetAllUsers()
以将其绑定到下拉列表
private void Bind_usersList()
{
var dictionary = Membership.GetAllUsers().Cast<MembershipUser>();
}
我正在尝试获取 userName 和 userID FromMembership.GetAllUsers()
以将其绑定到下拉列表
private void Bind_usersList()
{
var dictionary = Membership.GetAllUsers().Cast<MembershipUser>();
}
AMembershipUser
没有“userID”,但 aProviderUserKey
可能是Guid
(fe in SqlMembershipProvider
)。
这应该有效:
MembershipUserCollection members = Membership.GetAllUsers();
DdlUsers.DataSource = members.Cast<MembershipUser>()
.ToDictionary(m => m.ProviderUserKey, m => m.UserName);
DdlUsers.DataValueField = "Key";
DdlUsers.DataTextField = "Value";
DdlUsers.DataBind();