Imports System.Data
Imports System.Data.OleDb
Imports System.Configuration
Public Class Team
Inherits System.Web.UI.Page
Dim PageSize As Integer = 2
Dim CurrentPage As String
Dim TotalPages, TotalSize As Integer
Protected WithEvents Paginazione As System.Web.UI.WebControls.PlaceHolder
#Region " Codice generato da Progettazione Web Form "
'Chiamata richiesta da Progettazione Web Form.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents RTeam As System.Web.UI.WebControls.Repeater
Protected WithEvents lError As System.Web.UI.WebControls.Label
'NOTA: la seguente dichiarazione è richiesta da Progettazione Web Form.
'Non spostarla o rimuoverla.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: questa chiamata al metodo è richiesta da Progettazione Web Form.
'Non modificarla nell'editor del codice.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CurrentPage = Request("p")
If CurrentPage Is Nothing Then CurrentPage = 1
If Not Page.IsPostBack Then BindData()
End Sub
Sub BindData()
Dim DSN As String = ConfigurationSettings.AppSettings("connessione")
Dim Conn As OleDbConnection
Conn = New OleDbConnection(DSN)
Conn.Open()
'TEAM
Dim sqlTeam As String = "SELECT * FROM T_TEAM"
Dim CmdTeam As New OleDbDataAdapter(sqlTeam, Conn)
Dim ds As DataSet = New DataSet
Dim StartRecord As Integer = (Int32.Parse(CurrentPage) - 1) * Int32.Parse(PageSize)
CmdTeam.Fill(ds, StartRecord, Int32.Parse(PageSize), "Team")
RTeam.DataSource = ds
RTeam.DataBind()
Dim sqlConta As String = "SELECT COUNT(*)as Totale FROM T_Team"
Dim cmdConta As OleDbCommand = New OleDbCommand(sqlConta, Conn)
Dim reader As OleDbDataReader = cmdConta.ExecuteReader()
reader.Read()
TotalSize = reader("Totale")
reader.Close()
Conn.Close()
'Mostra l'avviso in alto con il numero dei risultati:
If TotalSize = 0 Then
lrisultati.Text = "non ci snon risultati per questa ricerca."
Else
TotalPages = Int32.Parse(TotalSize) \ Int32.Parse(PageSize) + 1
If Fix(TotalSize / PageSize) = TotalSize / PageSize Then TotalPages = TotalPages - 1
If TotalSize = 1 Then
lrisultati.Text += "Un risultato"
Else
lrisultati.Text += TotalSize & "risultati"
End If
Dim Endrecord As Integer = StartRecord + Int32.Parse(PageSize)
If Endrecord > TotalSize Then Endrecord = TotalSize
lrisultati.text +=" - pagina " & CurrentPage & " su " & Totalsize & " in totale - da " & startrecord + 1 & " a " &
End If
BuidPagers()
End Sub
Private Sub BuidPagers()
Dim i As Integer
Dim lb As Label
If TotalPages > 1 Then
lb = New Label
lb.Text = "Ci sono " & TotalPages & " pagine con i risultati: "
Paginazione.Controls.Add(lb)
For i = 1 To (TotalPages)
lb = New Label
lb.ID = "ThisPage" & i
If CurrentPage = i Then
lb.Text = "[
" & i & "] " & vbCrLf
Else
lb.Text = "[
" & i & "] " & vbCrLf
End If
Paginazione.Controls.Add(lb)
Next
End If
End Sub
End Class