Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/04/2005, 21:47
Avatar de davidalcaraz
davidalcaraz
 
Fecha de Ingreso: abril-2005
Mensajes: 34
Antigüedad: 19 años, 1 mes
Puntos: 0
Pregunta No me funciona el DataReader?

Hola amigos del foro. Aparentemente algo muy sencillo quiero preguntar, pero me sorprendio hasta que no lo hice. No me funciona la paginacion del datagrid utilizando datareader.
Bien tengo el datagrid con la propiedad Permitir paginacion checkeada y y funciona de maravilla utilizando un SqlDataAdapter y un Dataset(Como muestro en el segundo segmento de codigo. Pero al Implementarlo con datareader(como el primer segmento de codigo) me manda este error:

AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGrid1 when AllowPaging is set to true and the selected datasource does not implement ICollection.

Efectivamente si modifica la propiedad AllowCustomPagin ya no manda error pero tengo que programar la paginacion manualmente.

ALGUIEN PODRIA INDICARME SI EFECTIVAMENTE NO ME VA A FUNCIONAR ASI CON EL DATAREADER O SI HAY OTRA MANERA DE IMPLEMENTAR LA PAGINACION.?

----------------------------------------------------------------
CON DATAREADER

Public Conn As New SqlConnection("data source...
Dim dr As SqlDataReader
Dim SqlCommando As New SqlCommand("Select * from Customers", Conn)
Conn.Open()
dr = SqlCommando.ExecuteReader()
DataGrid1.DataSource = dr
DataGrid1.DataBind()
Conn.Close()
----------------------------------------------------------------
CON DATASET
Dim ds As New DataSet()
Dim da As New SqlDataAdapter()
da.SelectCommand = New SqlCommand()
da.SelectCommand.CommandText = "Select * from Customers"
da.SelectCommand.Connection = Conn
da.Fill(ds, "tabla")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
Conn.Close()
----------------------------------------------------------------
En el page index change puse esto...
DataGrid1.CurrentPageIndex = e.NewPageIndex
RellenarCustomers()