Código PHP:
using System;
using System.Data.SqlClient;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace prueba
{
/// <summary>
/// Descripción breve de paginado.
/// </summary>
public class paginado : System.Web.UI.Page
{
protected System.Data.DataSet dset= new DataSet();
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
if( !Page.IsPostBack )
{
EnlazaDatos();
}
}
private void EnlazaDatos()
{
SqlConnection conexion =new SqlConnection(Global.DbString);
conexion.Open();
SqlCommand mySqlCommand = new SqlCommand("SELECT productname,unitprice,unitsinstock FROM Products ORDER BY productname ASC", conexion);
SqlDataAdapter adapter= new SqlDataAdapter(mySqlCommand);
adapter.Fill(dset);
DataGrid1.DataSource=dset;
DataGrid1.DataBind();
adapter.Dispose();
mySqlCommand.Dispose();
conexion.Close();
}
private void DataGrid1_PageIndexChanged(object source,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
EnlazaDatos();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: llamada requerida por el Diseñador de Web Forms ASP.NET.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Método necesario para admitir el Diseñador, no se puede modificar
/// el contenido del método con el editor de código.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}