Datagrid paging problem

E

enak

I can not get my datagrid to page. I have a datagrid that
I can sort 2 of the columns. This works great. I added
paging and when I display the dg it shows 5 pages. (I am
showing page numbers at the bottom of the dg.)

When I click on the pages nothing happens until I get to
the last page. Then and only then is the last page
displayed. If I go back through the pages the second to
last page displayes the first page again.

As I trace the code through the debugger I can see that
the code is executed correctly but yet the pages don't
switch.

Here is my code:

<asp:datagrid id="dgCostCodes" runat="server"
Width="503px" AutoGenerateColumns="False"
AllowSorting="True"
PageSize="15" AllowPaging="True"
OnPageIndexChanged="dgCostCodes_Page">

..... Template Columns

</asp:datagrid>


CODEBEHIND

Private Sub dgBind()
Dim sSQL As String

If Not ds.Tables("tCostCodes") Is Nothing Then
ds.Tables("tCostCodes").Clear()
End If

sSQL = "select * from tblCostCodes Order By " & viewstate
("SortColumn") & " " & viewstate("AscDesc")

If cDb.getData(sSQL, "tCostCodes", ds) Then
Me.dgCostCodes.DataSource = ds.Tables("tCostCodes")
Me.dgCostCodes.DataBind()
End If

End Sub


Public Sub dgCostCodes_Page(ByVal sender As Object, ByVal
e As DataGridPageChangedEventArgs)
Me.dgCostCodes.CurrentPageIndex = e.NewPageIndex
Call dgBind()
End Sub


Thanks
enak
..
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top