[英]List of online users using membership asp.net
I want to have a list that contains online users in my web site i use this code in local host but it did't shows me any user. 我想在我的网站上有一个包含在线用户的列表,我在本地主机上使用此代码,但没有显示任何用户。 Can any body help me?
有谁能够帮助我? where did i make mistake?
我在哪里弄错了?
MembershipUserCollection users;
if (!IsPostBack)
{
// Bind users to ListBox.
List<MembershipUser> onlineUsers = new List<MembershipUser>();
foreach (MembershipUser user in Membership.GetAllUsers())
{
if (user.IsOnline)
{
onlineUsers.Add(user);
}
}
ListBox1.DataSource = users;
ListBox1.DataBind();
Try changing this line: 尝试更改此行:
ListBox1.DataSource = users;
To this: 对此:
ListBox1.DataSource = onlineUsers;
Also do not forget to set the DataKeyField and DataValueField properties on the ListBox1. 同样不要忘记在ListBox1上设置DataKeyField和DataValueField属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.