Visualizzazione dei risultati da 1 a 2 su 2

Discussione: allowpaging

  1. #1

    allowpaging

    Ragazzi non riesco a far andare la mia paginazione, vi riporto qui sotto il codice della pagina, questo è l'errore:

    "Dettagli eccezione: System.Web.HttpException: AllowCustomPaging deve avere valore true e VirtualItemCount deve essere impostata per un DataGrid con ID gridPrs quando AllowPaging è impostato su true e l'origine dati selezionata non implementa ICollection"


    Su uno script d'esempio ho trovato questo:

    "Also note that to utilize the default paging with a DataGrid Web control you must use a DataSet. That is, if you set AllowPaging to True but do not employ custom paging, you cannot bind a SqlDataReader or OleDbDataReader to the DataGrid Web control and implement paging. If you attempt to do so you will receive an error along the lines of: "To support paging, you must use an object that supports the ICollection interface." "


    Codice PHP:
    <%@ Page Language="vb" Debug="true" %>
    <%@ 
    Import Namespace="System.Data" %>
    <%@ 
    Import Namespace="System.Data.Oledb" %>
    <!
    DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    script runat="server">
     
    Sub Page_Load(sender as Objectas EventArgs)
        If 
    Not Page.IsPostBack then
          BindData
    ()
        
    End If    
      
    End Sub


    Sub BindData
    ()
    Dim conClsf As OleDbConnection
    Dim cmdMbrs 
    As OleDbCommand
    Dim rdrMbrs 
    As OleDbDataReader
    conClsf 
    = New OleDbConnection_
              
    "Provider=Microsoft.Jet.OLEDB.4.0;" _
              
    "Data Source=" server.mappath("plan_db.mdb") & _
              
    ";")
    conClsf.Open
     cmdMbrs 
    = New OleDbCommand_
                               
    "select * from Persone order by nome"_
                               conClsf
    )
       
    rdrMbrs cmdMbrs.ExecuteReader
       gridPrs
    .DataSource rdrMbrs
       gridPrs
    .DataBind
       rdrMbrs
    .Close                           
     cmdMbrs
    .Dispose                           
    conClsf
    .Close          
    End Sub

    Sub gridPrs_Paged
    (sender as Object as DataGridPageChangedEventArgs)
        
    gridPrs.CurrentPageIndex e.NewPageIndex
        BindData
    ()
      
    End Sub

    </script>
    <title>Planimetria</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <h2>Elenco Persone <%=now%></h2>
    <asp:DataGrid id="gridPrs" runat="server" 
       Border="0"
       Cellpadding="4"
       Cellspacing="0"
       AlternatingItemStyle-BackColor="#EFEFEF"
       ShowHeader="True"
       CssClass="DataGrid"
       HeaderStyle-BackColor="Black"
       HeaderStyle-ForeColor="White"
       HeaderStyle-Font-Bold="True"
       AllowPaging="True"
       PageSize="2"
       OnPageIndexChanged="gridPrs_Paged">
    </asp:DataGrid>
    </body>    
    </html> 

  2. #2
    OK, ho risolto...bastava popolare un dataset invece che un datareader :metallica

    La paginazione a quanto pare se pò fare solo popolando dei dataset

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 © 2025 vBulletin Solutions, Inc. All rights reserved.