try this
<%@ Page Language="C#" MasterPageFile="~/MasterPage/AdminMasterPage.master" AutoEventWireup="true" CodeFile="WhoIsOnline.aspx.cs" Inherits="Admin_WhoIsOnline" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<strong>
There are </strong>
<asp:Label ID="lblSessionCount" runat="server" Style="position: static" Font-Bold="True"></asp:Label><strong>
online users now</strong><br />
<br />
<asp:GridView ID="OnlineUserList" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="UserName" HeaderText="User Name" />
<asp:CheckBoxField DataField="IsOnline" HeaderText="Is Online" />
<asp:CheckBoxField DataField="IsApproved" HeaderText="Is Active" />
<asp:BoundField DataField="Email" HeaderText="Email" />
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<EmptyDataTemplate>
No User Online now
</EmptyDataTemplate>
</asp:GridView>
</asp:Content>
and in code behind
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Admin_WhoIsOnline : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MembershipUserCollection OnlineUsers = new MembershipUserCollection();
MembershipUserCollection AllUsers = new MembershipUserCollection();
AllUsers = Membership.GetAllUsers();
foreach (MembershipUser user in AllUsers)
{
if (user.IsOnline)
{
OnlineUsers.Add(user);
}
}
int OnlineUserCount = OnlineUsers.Count;
lblSessionCount.Text = OnlineUserCount.ToString();
OnlineUserList.DataSource = OnlineUsers;
OnlineUserList.DataBind();
}
}