se me desaparece el datagrid cuando hago la paginacion

  • Thread starter Luis Esteban Valencia
  • Start date
L

Luis Esteban Valencia

Hola, cuando hago click en la pagina 2 del datagrid se desaparece, hice un
breakpoint en cada linea del page_index_changed y siempre tiene la propiedad
visible = true

Este es mi codigo.


private void Page_Load(object sender, System.EventArgs e)

{

// Introducir aquí el código de usuario para inicializar la página

if(!Page.IsPostBack)

{

System.Configuration.AppSettingsReader configurationAppSettings = new
System.Configuration.AppSettingsReader();

sqlConnection1.ConnectionString =
((string)(configurationAppSettings.GetValue("Conexion1", typeof(string))));

cargarProveedores();

cargarComprobantes();

}

}



private void cargarProveedores()

{

SqlDataAdapter sqlDataAdatper2= new SqlDataAdapter("select UPPER(NANAME) AS
NANAME, * from prov_asw order by naname asc", sqlConnection1);

DataSet ds = new DataSet();

sqlDataAdatper2.Fill(ds, "proveedores");

comboproveedores.DataSource = ds;

comboproveedores.DataTextField = "naname".ToUpper();

comboproveedores.DataValueField = "nanum";

comboproveedores.DataBind();

}

private void cargarComprobantes()

{

SqlDataAdapter sqlDataAdatper2= new SqlDataAdapter("select * from
vwCompProveedores order by fecha", sqlConnection1);

DataSet ds = new DataSet();

sqlDataAdatper2.Fill(ds, "proveedores");

dgComprobantes.DataSource = ds;

dgComprobantes.DataBind();

}





private void dgComprobantes_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)

{

dgComprobantes.CurrentPageIndex = e.NewPageIndex;

dgComprobantes.DataBind();


}
 
J

John Saunders

Luis, yo no hablo muy bien el Espanol, pero mire:

private void dgComprobantes_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{

dgComprobantes.CurrentPageIndex = e.NewPageIndex;

cargarComprobantes();
dgComprobantes.DataBind();
}


Yo espero que eso se ayude!


John Saunders
 
L

Luis Esteban Valencia

That was the mistake. But I dont understand what Did I made wrong on my
logic??
 
J

John Saunders

Luis Esteban Valencia said:
That was the mistake. But I dont understand what Did I made wrong on my
logic??

Yes. You have to re-load the data before you data bind. You have to do this
for PageIndexChanged, for sorting and after changing EditItemIndex of
SelectedItemIndex.

One way to think of it is: if you're going to call DataBind, then there has
to be some data to bind to...

Buena Suerte,
John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top