次の方法で共有


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 列挙値の 1 つが返されます。

戻り値

データ ソース内のすべてのプロファイルに関するユーザー プロファイル情報を格納している 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および パラメーターを受け取る メソッドの ProfileInfo オーバーロードを使用して、GetAllProfilesユーザー プロファイルのオブジェクトのページをpageSize取得できます。

メソッドは 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 列挙値の 1 つが返されます。

pageIndex
Int32

取得する結果のページのインデックス。 pageIndex は 0 から始まります。

pageSize
Int32

取得する結果のページのサイズ。

totalRecords
Int32

このメソッドから制御が戻るとき、プロファイルの合計数を識別する整数が格納されます。 このパラメーターは初期化せずに渡されます。

戻り値

データ ソース内のすべてのプロファイルに関するユーザー プロファイル情報を格納している 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返される結果は、 パラメーターと pageSize パラメーターによってpageIndex制限されます。 パラメーターは pageSize 、 で返されるオブジェクトの ProfileInfo 最大数を ProfileInfoCollection識別します。 パラメーターは pageIndex 、返される結果のページを識別します。0 は最初のページを識別します。 totalRecordsパラメーターは、out指定された に基づいて、構成された applicationNameの非アクティブなユーザー プロファイルの合計数に設定されるauthenticationOptionパラメーターです。 たとえば、構成された applicationNamepageIndex に対して 13 人のユーザーがいて、値が 5 の値であるpageSize場合、ProfileInfoCollection返される には 6 番目から 10 番目のプロファイルが含まれます。 パラメーターは totalRecords 13 に設定されます。

メソッドは GetAllProfiles 、既定の GetAllProfiles プロファイル プロバイダーの メソッドを呼び出します。 既定のプロファイル プロバイダーは、プロファイル構成要素の 属性を使用してdefaultProvider指定されます。 既定のプロバイダー以外のプロファイル プロバイダーによって管理されるプロパティがユーザー プロファイルに含まれている場合、他のプロファイル プロバイダーのデータ ソースは検索されません。 既定のプロバイダー以外のプロファイル プロバイダーによって管理されているプロファイルを検索するには、 プロパティを使用して Providers プロファイル プロバイダーへの参照を取得し、プロバイダーの メソッドを GetAllProfiles 直接呼び出します。

こちらもご覧ください

適用対象