Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my gridview dissapears when i change page

VB
Protected Sub GridPrevistos_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles GridPrevistos.PageIndexChanging
        GridPrevistos.PageIndex = e.NewPageIndex
        GridPrevistos.DataBind()
    End Sub


pls remind that um using vb.net and asp.net
ty all :)
Posted
Updated 3-Jun-13 3:08am
v2

Hi,

Please check the event in the design, i think the pageIndexChanging event is not handled..

The error message is clearly stated..
 
Share this answer
 
v2
Comments
dp24 3-Jun-13 6:07am    
im sorry, im kinda newbie its asp! i dont get the error now, but the gridview dissapers when i press in page 2 or 3... can you help me?
Rockstar_ 3-Jun-13 6:15am    
go to the design of the gridview control and check whether the PageIndexChanging event is there or not?

Otherwise paste ur gridview design code here...
dp24 3-Jun-13 6:20am    
yes it is, pls check
http://i.imagebanana.com/img/amdt43hh/Capturar.PNG
Rockstar_ 3-Jun-13 6:23am    
Paste ur source code dear?
dp24 3-Jun-13 6:29am    
Protected Sub Mes_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Mes.SelectedIndexChanged
Me.anomes.Text = Me.Ano.SelectedValue & Me.Mes.SelectedValue

abre_ligacao()
MsgBox(Me.numempresa.Text)

Dim sqlprevistos As String = "SELECT top 100 num as Número,nome as Nome, ntrab as N_Trab,empresa as Empresa,cobranca as Cobrança,ROUND(remfixa*0.01,2) as Quota FROM Socios WHERE empresa='" & Me.numempresa.Text & "' ORDER BY num"
'Dim sqlprevistos As String = "SELECT * FROM cobranca"

Dim dsprevistos As DataSet = GetData(sqlprevistos)

If (dsprevistos.Tables.Count > 0) Then
GridPrevistos.DataSource = dsprevistos
GridPrevistos.DataBind()
Else
MsgBox("Não há dados para carregar!")
End If

fecha_ligacao()

End Sub
In your pageindexchanging event you wrote following lines
C#
GridPrevistos.PageIndex = e.NewPageIndex
GridPrevistos.DataBind()


But when writing GridPreVistos.DataBind(), you need to specify the data source again (as you may have provided when you bound this grid for the first time).

in simple words, after you specified the current pageIndex for the gridview you need to bind it again with dataSource. This time it will show the new page as value in e.NewPageIndex.


Hope this will help you.
 
Share this answer
 
Comments
dp24 3-Jun-13 10:25am    
thanks a lot mate!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900