Visualizzare le righe di un datagrid su più pagine
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<HTML>
<script language="VB" runat="server">
Dim MyConnection As OleDbConnection
Public Sub Page_Load(ByVal Sender As System.Object, ByVal E As System.EventArgs) Handles MyBase.Load
MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source=" & Server.MapPath("database/utenti.mdb"))
If Not (IsPostBack) Then
BindGrid()
End If
End Sub
Sub BindGrid()
Dim DS As DataSet
Dim MyCommand As OleDbDataAdapter
MyCommand = New OleDbDataAdapter("select * from utenti", MyConnection)
DS = New DataSet
MyCommand.Fill(DS, "utenti")
Dim Source As DataView = DS.Tables("utenti").DefaultView
MyDataGrid.DataSource = Source
MyDataGrid.DataBind()
End Sub
Sub MyDataGrid_PageIndexChanged(source As object, e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
</script>
<body>
<form runat="server" ID="Form1">
<ASP:DATAGRID id="MyDataGrid" runat="server" Width="700px" BorderWidth="1px" BorderStyle="None"
BorderColor="#CCCCCC" BackColor="White" CellPadding="3" EnableViewState="True" Font-Names="Verdana"
HeaderStyle-BackColor="#aaaadd" Font-Size="8pt" Font-Name="Verdana" PageSize="3" AllowPaging="True"
OnPageIndexChanged="MyDataGrid_PageIndexChanged">
<ItemStyle ForeColor="#000066"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
<PagerStyle Mode="NumericPages"></PagerStyle>
</ASP:DATAGRID><BR>
</form>
</body>
</HTML>