MembershipUserCollection.Count Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the number of membership user objects in the collection.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Property Value
The number of MembershipUser objects in the collection.
Implements
Examples
The following code example lists all of the users from the membership user data source, including a count of the total number of users.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
MembershipUserCollection users;
public void Page_Load(object sender, EventArgs args)
{
users = Membership.GetAllUsers();
UserGrid.DataSource = users;
UserGrid.DataBind();
NumUsers.Text = users.Count.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: User List</title>
</head>
<body>
<form id="form1" runat="server">
<h3>User List</h3>
Number of Users: <asp:Label id="NumUsers" runat="server" /><br />
<asp:DataGrid id="UserGrid" runat="server"
CellPadding="2" CellSpacing="1"
Gridlines="Both">
<HeaderStyle BackColor="darkblue" ForeColor="white" />
</asp:DataGrid>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim users As MembershipUserCollection
Public Sub Page_Load(sender As Object, args As EventArgs)
users = Membership.GetAllUsers()
UserGrid.DataSource = users
UserGrid.DataBind()
NumUsers.Text = users.Count.ToString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: User List</title>
</head>
<body>
<form id="form1" runat="server">
<h3>User List</h3>
Number of Users: <asp:Label id="NumUsers" runat="server" /><br />
<asp:DataGrid id="UserGrid" runat="server"
CellPadding="2" CellSpacing="1"
Gridlines="Both">
<HeaderStyle BackColor="darkblue" ForeColor="white" />
</asp:DataGrid>
</form>
</body>
</html>
Applies to
See also
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示