MembershipUserCollection.Count Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene il numero degli oggetti utenti di appartenenza nella raccolta.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Valore della proprietà
Numero di oggetti MembershipUser nella raccolta.
Implementazioni
Esempio
Nell'esempio di codice seguente sono elencati tutti gli utenti dall'origine dati dell'utente di appartenenza, incluso un conteggio del numero totale di utenti.
<%@ 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>
Si applica a
Vedi anche
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per