SqlProfileProvider.GetAllProfiles(ProfileAuthenticationOption, Int32, Int32, Int32) Metodo

Definizione

Recupera i dati dei profili utente presenti nell'origine dati.Retrieves user profile data for profiles in the data source.

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

Parametri

authenticationOption
ProfileAuthenticationOption

Uno dei valori dell'enumerazione ProfileAuthenticationOption che specifica se vengono restituiti profili di tipo anonimo, autenticato o entrambi.One of the ProfileAuthenticationOption values, specifying whether anonymous, authenticated, or both types of profiles are returned.

pageIndex
Int32

Indice della pagina di risultati da restituire.The index of the page of results to return. Il parametro pageIndex è in base zero.pageIndex is zero-based.

pageSize
Int32

Dimensione della pagina di risultati da restituire.The size of the page of results to return.

totalRecords
Int32

Quando termina, il metodo contiene un intero che identifica il numero totale di profili.When this method returns, contains an integer that identifies the total number of profiles. Questo parametro viene passato non inizializzato.This parameter is passed uninitialized.

Restituisce

Un oggetto ProfileInfoCollection che contiene le informazioni su tutti i profili utente presenti nell'origine dati.A ProfileInfoCollection containing user profile information for all of the profiles in the data source.

Eccezioni

pageIndex è minore di zero.pageIndex is less than zero.

-oppure--or- pageSize è minore di 1.pageSize is less than one.

-oppure--or- pageIndex moltiplicato per pageSize è maggiore di MaxValue.pageIndex multiplied by pageSize is larger than MaxValue.

Esempi

Nell'esempio di codice seguente vengono visualizzate le informazioni sul profilo per tutti i profili applicationName per l'oggetto configurato in pagine di dati.The following code example displays profile information for all of the profiles for the configured applicationName in pages of data.

<%@ 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()
{
  SqlProfileProvider p = (SqlProfileProvider)Profile.Providers["SqlProvider"]; 
  ProfileGrid.DataSource = p.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()

  Dim p As SqlProfileProvider = CType(Profile.Providers("SqlProvider"), SqlProfileProvider) 
  ProfileGrid.DataSource = p.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>

Commenti

Il GetAllProfiles metodo viene utilizzato per recuperare le informazioni sul profilo per i profili dall'origine dati per l'applicazione specificata applicationName dall'attributo nel file di configurazione.The GetAllProfiles method is used to retrieve profile information for profiles from the data source for the application specified by the applicationName attribute in the configuration file. Utilizzare il authenticationOption parametro per specificare se si desidera che vengano cercati solo profili anonimi, solo profili autenticati o tutti i profili.Use the authenticationOption parameter to specify whether you want only anonymous profiles, only authenticated profiles, or all profiles to be searched.

I risultati restituiti da GetAllInactiveProfiles sono limitati pageIndex dai parametri e pageSize .The results returned by GetAllInactiveProfiles are constrained by the pageIndex and pageSize parameters. Il pageSize parametro identifica il numero massimo di ProfileInfo oggetti da restituire nell'oggetto ProfileInfoCollection.The pageSize parameter identifies the maximum number of ProfileInfo objects to return in the ProfileInfoCollection. Il pageIndex parametro identifica la pagina di risultati da restituire; 0 identifica la prima pagina.The pageIndex parameter identifies which page of results to return; 0 identifies the first page. Il totalRecords parametro è un out parametro impostato sul numero totale di profili utente inattivi per l'oggetto configurato applicationName, in base ai authenticationOption parametri e userInactiveSinceDate .The totalRecords parameter is an out parameter that is set to the total number of inactive user profiles for the configured applicationName, based on the authenticationOption and userInactiveSinceDate parameters. Se, ad esempio, sono presenti 13 utenti per l' applicationNameoggetto configurato e pageIndex il valore è 1 con pageSize un valore pari a ProfileInfoCollection 5, l'oggetto restituito conterrà il sesto fino al decimo profilo.For example, if there are 13 users for the configured applicationName, and the pageIndex value is 1 with a pageSize of 5, the ProfileInfoCollection returned will contain the sixth through the tenth profiles. Il totalRecords parametro verrà impostato su 13.The totalRecords parameter will be set to 13.

Si applica a

Vedi anche