使用会员asp.net在线用户列表 [英] List of online users using membership asp.net

查看:192
本文介绍了使用会员asp.net在线用户列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个包含在我的网站我使用本地主机此code在线用户列表,但我以前不显示我的任何用户。有谁能够帮助我?在哪里我犯错?

  MembershipUserCollection用户;
        如果(!的IsPostBack)
        {
            //绑定用户列表框。
            清单<&的MembershipUser GT; onlineUsers =新的List<&的MembershipUser GT;();
            的foreach(的MembershipUser用户在Membership.GetAllUsers())
            {                如果(user.IsOnline)
                {
                    onlineUsers.Add(用户);                }            }
            ListBox1.DataSource =用户;
            ListBox1.DataBind();


解决方案

尝试改变这一行:

  ListBox1.DataSource =用户;

要这样:

  ListBox1.DataSource = onlineUsers;

另外不要忘记上为ListBox设置DataKeyField和DataValueField属性。

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.

这篇关于使用会员asp.net在线用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆