Help With Paging?!

Tmuldoon

New member
Joined
Apr 15, 2005
Messages
4
Programming Experience
Beginner
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodePagingInDataGridWebControlVisualBasic.asp

I still have some issues. I used the MSDN code and it sort of works.
Now the paging works, but when I hit the number - it does not show my
records until I hit the search button again. I thought it would go to
the next records automatically. Not sure why? Do I need to do some
sort of refresh at the button level?

WHY DOESN'T IT PAGE AUTOMATICALLY!???

[Plus I also do not understand this line:

dsQuery = CType(Session("dataset"), DataSet1). I already have a
dataset defined at design time - what does this do? ]

Here is my code:
- my dataset is called 'ds'

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

With dg
.AllowPaging = True
.PagerStyle.Mode = PagerMode.NumericPages
.PageSize = 5
.PagerStyle.PageButtonCount = 5
End With
If IsPostBack Then
ds = CType(Session("dataset"), DataSet1)
Else
daQuery.Fill(ds)
Session("dataset") = ds
DataBind()
End If
End Sub

The button code->filters out data with a dataview. So after the page
button is pressed - one gets a blank screen untill the button is
pressed again - then it moves to the next results.

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn.Click
Dim Count As Integer

Dim dv As DataView = ds.Tables("DB").DefaultView
dv.RowFilter = "Title like '%" & txt.Text & "%' OR Address like
'%" & txt.Text & "%'"
Count = dv.Count
dg.DataSource = dv
dg.DataBind()
lblCount.Text = Count

End Sub

Paging:

- Hide quoted text -
- Show quoted text -
Private Sub dg_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dg.PageIndexChanged
dg.CurrentPageIndex = e.NewPageIndex
dg.DataBind()
End Sub
 
i'm not that familiar with asp (i dont usually check that section of this forum) but from the sounds of it all you need to do is copy the code from the search button's click event @ the end of the paging sub
 
Back
Top