nel tuo codice ho aggiunto questa roba e non riesco a farlo andare.
codice:
Public Function getPage(ByVal idPostPager As String)
Dim myconn As New OleDbConnection(ConfigurationSettings.AppSettings("dbForum"))
Dim sqlStr As New loadSql()
myconn.Open()
Dim mycomm As New OleDbDataAdapter(sqlStr.setParams(idPostPager, "selPostForTopicPage"), myconn)
Dim tab As DataSet = New DataSet()
Dim firstPost As Integer = (CInt(1) - 1) * (maxPostPerPage)
mycomm.Fill(tab, firstPost, maxPostPerPage, "tabDati")
Dim listaPost As New DataGrid()
listaPost.PageSize = maxPostPerPage
listaPost.DataSource = tab
listaPost.DataBind()
Dim i, PosRecord, PaginaDaVisualizzare As Integer
Dim IDRicerca As String
IDRicerca = idPostPager 'poniamo che cerchi il record con ID 137
For i = 0 To tab.Tables(0).Rows.Count - 1 'MyTable è il datasource del datagrid
If tab.Tables(0).Rows(i)("tabPost.idPost") = IDRicerca Then
Exit For
End If
Next i
PosRecord = i
'a questo punto hai salvato in "i" la osizione del record
Dim PaginaDaVedere As Integer
For i = 0 To listaPost.PageCount - 1 'TuoDtg è il tuo datagrid
If (listaPost.PageSize * (i + 1)) >= PosRecord And (listaPost.PageSize * (i)) <= PosRecord Then
Exit For
End If
Next i
PaginaDaVisualizzare = i
mycomm.Dispose()
myconn.Dispose()
myconn.Close()
Return (PaginaDaVisualizzare)
End Function
in pratica devo creare un dataGrid ogni volta che eseguo la funzione perchè nella pagina che la richiama, il datagrid non c'è.
Trova sempre la pagina 0.