ProfileManager.GetNumberOfProfiles(ProfileAuthenticationOption) 方法

定义

获取数据源中的配置文件数量。

public:
 static int GetNumberOfProfiles(System::Web::Profile::ProfileAuthenticationOption authenticationOption);
public static int GetNumberOfProfiles (System.Web.Profile.ProfileAuthenticationOption authenticationOption);
static member GetNumberOfProfiles : System.Web.Profile.ProfileAuthenticationOption -> int
Public Shared Function GetNumberOfProfiles (authenticationOption As ProfileAuthenticationOption) As Integer

参数

authenticationOption
ProfileAuthenticationOption

ProfileAuthenticationOption 枚举值之一,它指定是返回匿名配置文件、经过身份验证的配置文件还是同时返回两者。

返回

Int32

数据源中的配置文件数量。

示例

下面的代码示例显示已配置 applicationName 的所有配置文件的配置文件信息,并返回配置文件数。

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Profile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

public void Page_Load()
{
  TotalLabel.Text = ProfileManager.GetNumberOfProfiles(ProfileAuthenticationOption.All).ToString();
  GetProfiles();
}

private void GetProfiles()
{
  ProfileGrid.DataSource = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
  ProfileGrid.DataBind();
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: Find Profiles</title>
</head>
<body>

<form id="form1" runat="server">
  <h3>Profile List</h3>

  <asp:Label id="TotalLabel" runat="server" text="0" /> Profiles found.<br />

  <asp:GridView id="ProfileGrid" runat="server"
                CellPadding="2" CellSpacing="1" Gridlines="Both">
    <HeaderStyle BackColor="darkblue" ForeColor="white" />
  </asp:GridView>

</form>

</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Profile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

Public Sub Page_Load()
  TotalLabel.Text = ProfileManager.GetNumberOfProfiles(ProfileAuthenticationOption.All).ToString()
  GetProfiles()
End Sub

Private Sub GetProfiles()
  ProfileGrid.DataSource = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)
  ProfileGrid.DataBind()
End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: Find Profiles</title>
</head>
<body>

<form id="form1" runat="server">
  <h3>Profile List</h3>

  <asp:Label id="TotalLabel" runat="server" text="0" /> Profiles found.<br />

  <asp:GridView id="ProfileGrid" runat="server"
                CellPadding="2" CellSpacing="1" Gridlines="Both">
    <HeaderStyle BackColor="darkblue" ForeColor="white" />
  </asp:GridView>

</form>

</body>
</html>

注解

该方法 GetNumberOfProfiles 用于从配置文件中属性指定的 applicationName 应用程序的数据源中检索所有用户配置文件的计数。 authenticationOption使用参数指定是只希望匿名配置文件、仅经过身份验证的配置文件还是要搜索的所有配置文件。

适用于

另请参阅