am using custom pagination

using the following

Case "Prev"
If GridView1.PageIndex > 0 Then
GridView1.PageIndex = Int32.Parse(GridView1.PageCount) - 1
End If


Case "Next"
If GridView1.PageIndex < (GridView1.PageCount - 1) Then


GridView1.PageIndex = Int32.Parse(GridView1.PageCount) + 1
End If


for first and last its wrking properly

but in using this two pagination is not proper
if i click on next the last page gets dispalyed and if clicked on pevious nothing happens no change

second thing is
i get some filtered data for gridview
suppose the filtered data has 2 pages on gridview , so when i click next it shld dispaly 2nd page instead its reset to the whole dataset records

how do i correct the things