Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2000
    Messaggi
    38

    Problemi paginazione DataGrid.

    Ciao,
    Ho un arrey, con questo arrey vado a popolare un DataGrid, tutto mi funziona correttamente,
    Solo che non mi funziona la paginazione, ovvero quando clicco sui numeriper passare alle pagine successive, mi compare sempre la prima pagina.

    Questo è il codiche che utilizzo: per creare il datagrid.
    codice:
      Dim Tabella As New DataTable
       Dim dr As DataRow
    
           Tabella.Columns.Add(New DataColumn("Codice 
     Richiesta", GetType(String)))
           Tabella.Columns.Add(New DataColumn("Richiesta", GetType(String)))
           Tabella.Columns.Add(New DataColumn("Data 
     Richiesta", GetType(String)))
           Tabella.Columns.Add(New DataColumn("Priorita", GetType(String)))
           Tabella.Columns.Add(New DataColumn("Stato", GetType(String)))
    
       Dim k As Integer
    
       For k = 0 To TicketList.Length() - 1  'Ciclo sulle righe 
       '***********   Compongo Le Celle  ****************************
       
       dr = Tabella.NewRow()
       dr(0) = "<a href=DettaglioChiamata.aspx?TicketID=" + TicketList(k).Case_ID + ">" + TicketList(k).Case_ID + "</a>"
       dr(1) = TicketList(k).Summary
       dr(2) = TicketList(k).Create_Time
       dr(3) = icketList(k).Priorita
       dr(4) = TicketList(k).Status
    
       Tabella.Rows.Add(dr)
       Next k
    
       Dim dv As New DataView(Tabella)
      ' Load this data only once.
       
       ItemsGrid.DataSource = dv
       ItemsGrid.DataBind()

    Questo è il codiche totale della pagina.



    codice:
    Imports System.Data
    
    Public Class Segnalazioni
        Inherits System.Web.UI.Page
    
    #Region " Web Form Designer Generated Code "
    
        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    
        End Sub
        Protected WithEvents VisualizzaStatoTicket As System.Web.UI.WebControls.DropDownList
        Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
        Protected WithEvents Panel As System.Web.UI.WebControls.Panel
        Protected WithEvents t1 As System.Web.UI.HtmlControls.HtmlTable
        Protected WithEvents ItemsGrid As System.Web.UI.WebControls.DataGrid
        Protected WithEvents noTicket As System.Web.UI.WebControls.Label
    
        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration As System.Object
    
        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub
    
    #End Region
    
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            Dim TicketList As UNIBO_TicketList.GetListOutputMapGetListValues()
            Dim TicketService As UNIBO_TicketList.UNIBO_TicketListService
            Dim Priorita As String
            Dim Stato As String
    
            Dim qualification As String
            Dim i As Integer
            Dim col As Integer
            Dim row As Integer
            Dim authInfo As UNIBO_TicketList.AuthenticationInfo
    
            On Error Resume Next
    
            authInfo = New UNIBO_TicketList.AuthenticationInfo
            authInfo.userName = "Massimo"
            authInfo.password = "kid"
    
            TicketService = New UNIBO_TicketList.UNIBO_TicketListService
            TicketService.AuthenticationInfoValue = authInfo
            If VisualizzaStatoTicket.SelectedValue = "Tutte" Then
                qualification = "('230000009'=" + """" + "MAINHELPDESK" + """" + ") AND ('2'=" + """" + authInfo.userName + """" + ")"  'Con Filtro
            Else
                '  qualification = "('230000000'=" + """" + "MAINHELPDESK" + """" + ") AND ('200000003'=" + """" + "Servizi IT" + """" + ") AND ('7' = 0)"
                qualification = "('230000009'=" + """" + "MAINHELPDESK" + """" + ") AND ('2'=" + """" + authInfo.userName + """" + ") AND ('7' < 5)"  'Con Filtro
            End If
    
            TicketList = TicketService.OpGetList(qualification)
    
            If TicketList.Length = Nothing Then
                noTicket.Visible = True
                noTicket.Text = "Nessun ticket presente nel Database."
            Else
    
                If Not IsPostBack Then
    
                    Dim Tabella As New DataTable
                    Dim dr As DataRow
    
                    Tabella.Columns.Add(New DataColumn("Codice 
     Richiesta", GetType(String)))
                    Tabella.Columns.Add(New DataColumn("Richiesta", GetType(String)))
                    Tabella.Columns.Add(New DataColumn("Data 
     Richiesta", GetType(String)))
                    Tabella.Columns.Add(New DataColumn("Priorita", GetType(String)))
                    Tabella.Columns.Add(New DataColumn("Stato", GetType(String)))
    
                    Dim k As Integer
    
                    For k = 0 To TicketList.Length() - 1  'Ciclo sulle righe 
                        '***********   Compongo Le Celle  ****************************
                        dr = Tabella.NewRow()
                        dr(0) = "<a href=DettaglioChiamata.aspx?TicketID=" + TicketList(k).Case_ID + ">" + TicketList(k).Case_ID + "</a>"
                        dr(1) = TicketList(k).Summary
                        dr(2) = TicketList(k).Create_Time
    
                        Select Case TicketList(k).Request_Urgency.ToString      '****GESTIONE PRIORITA****
                            Case "Low"
                                Priorita = "Bassa"
                            Case "Urgent"
                                Priorita = "Urgente"
                        End Select
    
                        dr(3) = Priorita
                        Dim str As String = TicketList(k).Status
                        Select Case TicketList(k).Status.ToString  '****GESTIONE STATO****
    
                            Case "New"
                                Stato = "Nuovo"
                            Case "Assigned"
                                Stato = "Assegnato"
                            Case "Work In Progress"
                                Stato = "In Lavorazione"
                            Case "Pending"
                                Stato = "Sospeso"
                            Case "Resolved"
                                Stato = "Risolto"
                            Case "Closed"
                                Stato = "Chiuso"
                        End Select
    
                        dr(4) = Stato
    
                        Tabella.Rows.Add(dr)
                    Next k
    
                    Dim dv As New DataView(Tabella)
                    ' Load this data only once.
    
                    ItemsGrid.DataSource = dv
                    ItemsGrid.DataBind()
                End If
            End If
        End Sub
    End Class

  2. #2
    Come hai impostato le proprietà di paginazione della griglia?

    Io ho fatto una prova con
    AllowCustomPaging = False
    AllowPaging = true


    Nel codebehind

    codice:
     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            If Not Page.IsPostBack Then
                
            ' qui metti tutto quello che devo fare per ottenere i dati da mettere nella griglia
                Session("dati") = Tabella
                BindGrid()
            End If
        End Sub

    'centralizzo in un punto solo il bind dei dati alla grigglia
    codice:
      Private Sub BindGrid()
            Dim dt As DataTable
            dt = Session("dati")
            Me.DataGrid1.DataSource = dt
            Me.DataGrid1.DataBind()
        End Sub
    Gestisco l'evento di cambio pagina
    codice:
    Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
            Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
            BindGrid()
        End Sub

    Fammi sapere
    Ciao
    Kalman

    PS: array e non arrey!!!
    Kalman

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2000
    Messaggi
    38
    Ok Funziona
    Grazie Mille.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.