簡體   English   中英

使用會員身份asp.net的在線用戶列表

[英]List of online users using membership asp.net

我想在我的網站上有一個包含在線用戶的列表,我在本地主機上使用此代碼,但沒有顯示任何用戶。 有誰能夠幫助我? 我在哪里弄錯了?

  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();

嘗試更改此行:

ListBox1.DataSource = users;

對此:

ListBox1.DataSource = onlineUsers;

同樣不要忘記在ListBox1上設置DataKeyField和DataValueField屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM