ProfileManager.GetAllProfiles 方法

定义

在数据源中检索配置文件的用户配置文件数据。

重载

GetAllProfiles(ProfileAuthenticationOption)

在数据源中检索配置文件的用户配置文件数据。

GetAllProfiles(ProfileAuthenticationOption, Int32, Int32, Int32)

检索用户配置文件数据的页面。

GetAllProfiles(ProfileAuthenticationOption)

在数据源中检索配置文件的用户配置文件数据。

public:
 static System::Web::Profile::ProfileInfoCollection ^ GetAllProfiles(System::Web::Profile::ProfileAuthenticationOption authenticationOption);
public static System.Web.Profile.ProfileInfoCollection GetAllProfiles (System.Web.Profile.ProfileAuthenticationOption authenticationOption);
static member GetAllProfiles : System.Web.Profile.ProfileAuthenticationOption -> System.Web.Profile.ProfileInfoCollection
Public Shared Function GetAllProfiles (authenticationOption As ProfileAuthenticationOption) As ProfileInfoCollection

参数

authenticationOption
ProfileAuthenticationOption

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

返回

ProfileInfoCollection

一个 ProfileInfoCollection,包含数据源中所有配置文件的用户配置文件信息。

示例

下面的代码示例显示已配置 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>

注解

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

可以使用采用附加pageIndex参数pageSize的方法的ProfileInfo重载GetAllProfiles检索用户配置文件的对象页。

该方法 GetAllProfiles 调用 GetAllProfiles 默认配置文件提供程序的方法。 默认配置文件提供程序是使用defaultProvider配置文件配置元素的属性指定的。 如果用户配置文件包含由默认提供程序以外的配置文件提供程序管理的属性,则不会搜索其他配置文件提供程序的数据源。 若要查找由默认提供程序以外的配置文件提供程序管理的配置文件,请使用 Providers 属性获取对配置文件提供程序的引用,并直接调用 GetAllProfiles 提供程序的方法。

另请参阅

适用于

GetAllProfiles(ProfileAuthenticationOption, Int32, Int32, Int32)

检索用户配置文件数据的页面。

public:
 static System::Web::Profile::ProfileInfoCollection ^ GetAllProfiles(System::Web::Profile::ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, [Runtime::InteropServices::Out] int % totalRecords);
public static System.Web.Profile.ProfileInfoCollection GetAllProfiles (System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords);
static member GetAllProfiles : System.Web.Profile.ProfileAuthenticationOption * int * int * int -> System.Web.Profile.ProfileInfoCollection
Public Shared Function GetAllProfiles (authenticationOption As ProfileAuthenticationOption, pageIndex As Integer, pageSize As Integer, ByRef totalRecords As Integer) As ProfileInfoCollection

参数

authenticationOption
ProfileAuthenticationOption

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

pageIndex
Int32

要返回的结果页的索引。 pageIndex 从零开始。

pageSize
Int32

要返回的结果页的大小。

totalRecords
Int32

此方法返回时,会包含一个表示配置文件总数的整数。 此参数未经初始化即被传递。

返回

ProfileInfoCollection

一个 ProfileInfoCollection,包含数据源中所有配置文件的用户配置文件信息。

示例

下面的代码示例显示数据页中配置 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">

int pageSize = 5;
int totalProfiles;
int totalPages;
int currentPage = 1;

public void Page_Load()
{
  if (!IsPostBack)
  {
    GetProfiles();
  }
}

private void GetProfiles()
{
  ProfileGrid.DataSource = ProfileManager.GetAllProfiles(
                               ProfileAuthenticationOption.All,
                               currentPage - 1, pageSize, out totalProfiles);
  totalPages = ((totalProfiles - 1) / pageSize) + 1;

  // Ensure that we do not navigate past the last page of Profiles.

  if (currentPage > totalPages)
  {
    currentPage = totalPages;
    GetProfiles();
    return;
  }

  ProfileGrid.DataBind();
  CurrentPageLabel.Text = currentPage.ToString();
  TotalPagesLabel.Text = totalPages.ToString();

  if (currentPage == totalPages)
    NextButton.Visible = false;
  else
    NextButton.Visible = true;

  if (currentPage == 1)
    PreviousButton.Visible = false;
  else
    PreviousButton.Visible = true;

  if (totalProfiles <= 0)
    NavigationPanel.Visible = false;
  else
    NavigationPanel.Visible = true;
}

public void NextButton_OnClick(object sender, EventArgs args)
{
  currentPage = Convert.ToInt32(CurrentPageLabel.Text);
  currentPage++;
  GetProfiles();
}

public void PreviousButton_OnClick(object sender, EventArgs args)
{
  currentPage = Convert.ToInt32(CurrentPageLabel.Text);
  currentPage--;
  GetProfiles();
}

</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:Panel id="NavigationPanel" Visible="false" runat="server">
    <table border="0" cellpadding="3" cellspacing="3">
      <tr>
        <td style="width:100">Page <asp:Label id="CurrentPageLabel" runat="server" />
            of <asp:Label id="TotalPagesLabel" runat="server" /></td>
        <td style="width:60"><asp:LinkButton id="PreviousButton" Text="< Prev"
                            OnClick="PreviousButton_OnClick" runat="server" /></td>
        <td style="width:60"><asp:LinkButton id="NextButton" Text="Next >"
                            OnClick="NextButton_OnClick" runat="server" /></td>
      </tr>
    </table>
  </asp:Panel>

  <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">

Dim pageSize As Integer = 5
Dim totalProfiles As Integer 
Dim totalPages As Integer 
Dim currentPage As Integer = 1

Public Sub Page_Load()
  If Not IsPostBack Then  
    GetProfiles()
  End If
End Sub

Private Sub GetProfiles()

  ProfileGrid.DataSource = ProfileManager.GetAllProfiles( _
                               ProfileAuthenticationOption.All, _
                               currentPage - 1, pageSize, totalProfiles)
  totalPages = ((totalProfiles - 1) \ pageSize) + 1

  ' Ensure that we do not navigate past the last page of Profiles.

  If currentPage > totalPages Then
    currentPage = totalPages
    GetProfiles()
    Return
  End If

  ProfileGrid.DataBind()
  CurrentPageLabel.Text = currentPage.ToString()
  TotalPagesLabel.Text = totalPages.ToString()

  If currentPage = totalPages Then
    NextButton.Visible = False
  Else
    NextButton.Visible = True
  End If

  If currentPage = 1 Then
    PreviousButton.Visible = False
  Else
    PreviousButton.Visible = True
  End If

  If totalProfiles <= 0 Then
    NavigationPanel.Visible = False
  Else
    NavigationPanel.Visible = True
  End If
End Sub

Public Sub NextButton_OnClick(sender As Object, args As EventArgs)
  currentPage = Convert.ToInt32(CurrentPageLabel.Text)
  currentPage += 1
  GetProfiles()
End SUb

Public Sub PreviousButton_OnClick(sender As Object, args As EventArgs)
  currentPage = Convert.ToInt32(CurrentPageLabel.Text)
  currentPage -= 1
  GetProfiles()
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:Panel id="NavigationPanel" Visible="False" runat="server">
    <table border="0" cellpadding="3" cellspacing="3">
      <tr>
        <td style="width:100">Page <asp:Label id="CurrentPageLabel" runat="server" />
            of <asp:Label id="TotalPagesLabel" runat="server" /></td>
        <td style="width:60"><asp:LinkButton id="PreviousButton" Text="< Prev"
                            OnClick="PreviousButton_OnClick" runat="server" /></td>
        <td style="width:60"><asp:LinkButton id="NextButton" Text="Next >"
                            OnClick="NextButton_OnClick" runat="server" /></td>
      </tr>
    </table>
  </asp:Panel>

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

</form>

</body>
</html>

注解

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

返回 GetAllInactiveProfiles 的结果受 pageIndex 参数的约束 pageSize 。 该pageSize参数标识在 . ProfileInfoCollection中返回的最大对象数ProfileInfo。 该 pageIndex 参数标识要返回的结果页;零标识第一页。 该totalRecords参数是一个out参数,该参数设置为根据提供的authenticationOption配置的applicationName非活动用户配置文件总数。 例如,如果配置 applicationName有 13 个用户,并且 pageIndex 值为 pageSize 5 的用户,则 ProfileInfoCollection 返回的用户将包含第六到第十个配置文件。 参数 totalRecords 将设置为 13。

该方法 GetAllProfiles 调用 GetAllProfiles 默认配置文件提供程序的方法。 默认配置文件提供程序是使用defaultProvider配置文件配置元素的属性指定的。 如果用户配置文件包含由默认提供程序以外的配置文件提供程序管理的属性,则不会搜索其他配置文件提供程序的数据源。 若要查找由默认提供程序以外的配置文件提供程序管理的配置文件,请使用 Providers 属性获取对配置文件提供程序的引用,并直接调用 GetAllProfiles 提供程序的方法。

另请参阅

适用于