Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/10/2004, 05:40
miguelinso
 
Fecha de Ingreso: agosto-2004
Mensajes: 9
Antigüedad: 19 años, 8 meses
Puntos: 0
gracias por la respuesta, pero lo que necesito es el código en c# porque no sé desarrollar la idea que me dices, y me imagino que esta manera de presentar un datagrid ya se habrá hecho más veces. Mi código es algo así:
************************************************** **

using System;
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;
using System.Data.Odbc;
using System.Configuration;


namespace Aplicacion
{

public class _default1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid MyDataGrid;
protected System.Web.UI.WebControls.Label lblEnabled;
protected System.Web.UI.WebControls.Label lblCurrentIndex;
protected System.Web.UI.WebControls.Label lblPageCount;
protected System.Web.UI.WebControls.Label lblCustom;
protected System.Web.UI.WebControls.Label lblPageSize;
protected System.Web.UI.WebControls.Label lblVirtual;

protected ComponentArt.Web.UI.Menu Menu1;

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()
{
OdbcConnection conexion;
OdbcCommand comando;
OdbcDataAdapter objDataAdapter;

//Comprueba que el usuario y password son correctos
AppSettingsReader rdr =new AppSettingsReader();
string strCadenaConexionBD = rdr.GetValue("ConexionBDASA",typeof(string)).ToStr ing();

conexion= new OdbcConnection();
conexion.ConnectionString=strCadenaConexionBD;
conexion.Open();

comando=new OdbcCommand();
comando.Connection=conexion;
comando.CommandText= "select terapia_id, terapia_descripcion from terapia order by terapia_id";

objDataAdapter = new OdbcDataAdapter(comando);
objDataAdapter.Fill(dset);

DataGrid1.DataSource=dset;
DataGrid1.DataBind();
objDataAdapter.Dispose();
comando.Dispose();
conexion.Close();
}

private void DataGrid1_PageIndexChanged(object source,System.Web.UI.WebControls.DataGridPageChang edEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
EnlazaDatos();
}



#region Código generado por el Diseñador de Web Forms
override protected void OnInit(EventArgs e)
{

InitializeComponent();
base.OnInit(e);
}


private void InitializeComponent()
{
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEvent Handler(this.DataGrid1_PageIndexChanged);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexCh anged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{

}

}
}
************************************************** **

Este es mi codigo, donde, pro cierto, solo consigo ver la primera pagina ... y no sé por qué ...
alguien puede ayudarme??

gracias again