473,657 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Paging by example - help - still no luck....

Hello,

I was looking at the example provided on:
http://www.4guysfromrolla.com/webtech/072101-1.2.shtml
for paging.

I am using Visual Studio 2003 - Microsoft Development Environment 2003

For paging the page url mentions setting properties to be set as:

AllowPaging="Tr ue"
PageSize="15"
OnPageIndexChan ged="dgPopularF AQs_Paged">

Ok. I am looking at my datagrid in the design view - there is a Allow
Paging, PageSize - but no OnPageIndexChan ged!!

I went to the code behine - at the top selected my datagrid in the top
left drop down menu, and could not find OnPageIndexChan ged in the
declarations menu. There is a 'PageIndexChang ed' changed - is that it?

Well, I put this code in that area (using a Dataset called ds):
Private Sub dg_PageIndexCha nged(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridPageChanged EventArgs) Handles
dg.PageIndexCha nged
dg.CurrentPageI ndex = e.NewPageIndex
dg.DataBind()
End Sub

The paging numbers show up on the grid, but when I hit any of the
numbers - the same screen shows up - 10 records, it does not advance
(set to 10 in the property builder). It never advances. In my page
load I have this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then

dgDataBind()
End If
End Sub

Any help?

Thanks,

Tmuld

Nov 21 '05 #1
7 1124
Tmuld,

Why don't you just use the samples on MSDN for paging a datagrid, they are
in my opinion very well.

One of them
http://msdn.microsoft.com/library/de...isualBasic.asp

I hope this helps,

Cor
Nov 21 '05 #2
Thanks - it does work very well!

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?

[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.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
With dg
.AllowPaging = True
.PagerStyle.Mod e = PagerMode.Numer icPages
.PageSize = 5
.PagerStyle.Pag eButtonCount = 5
End With
If IsPostBack Then
ds = CType(Session(" dataset"), DataSet1)
Else
daQuery.Fill(ds )
Session("datase t") = 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.EventArg s) 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:

Private Sub dg_PageIndexCha nged(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridPageChanged EventArgs) Handles
dg.PageIndexCha nged
dg.CurrentPageI ndex = e.NewPageIndex
dg.DataBind()
End Sub

Nov 21 '05 #3
Tmuld,

A webpage is not persistent, what means that with every send and get back
all the data on serverside is removed. For that are some solutions for with
is the session the most simple. The most simple because it can fit
automatically (serialized) the dataset.

Therefore you have to set that dataset again when there is a postback to the
session (and as well when you do a fill to renew it).

Your other question is what I am always struggling with as well, so take
some time to find that.

Cor
Nov 21 '05 #4
It is strange it is actually working in the background, but only
appears after the search button is pressed again.

I am thinking the currentrowindex is updated, but only will show when
requeried.

I thought the Databind() property refreshed to the new index.

Still no luck....
Nov 21 '05 #5
Tmuld,

I made a complete working sample from that what I showed on MSDN in the
link.

Maybe you can try it.
\\\Needs only a webdagrid.
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim ds As DataSet
DataGrid1.Allow Paging = True
DataGrid1.Pager Style.Mode = PagerMode.Numer icPages
DataGrid1.PageS ize = 5
DataGrid1.Pager Style.PageButto nCount = 5
If IsPostBack Then
ds = DirectCast(Sess ion("dataset"), DataSet)
DataGrid1.DataS ource = ds
Else
ds = New DataSet
Dim dt As New DataTable
dt.Columns.Add( "Mycolumn")
For i As Integer = 0 To 100
dt.LoadDataRow( New Object() {i.ToString}, True)
Next
ds.Tables.Add(d t)
Session("datase t") = ds
DataGrid1.DataS ource = ds
DataBind()
End If
End Sub

Private Sub DataGrid1_PageI ndexChanged(ByV al source As Object, ByVal e _
As System.Web.UI.W ebControls.Data GridPageChanged EventArgs) _
Handles DataGrid1.PageI ndexChanged
DataGrid1.Curre ntPageIndex = e.NewPageIndex
DataGrid1.DataB ind()
End Sub
///

I hope this helps a little bit?

Cor
Nov 21 '05 #6
Hey Cor! I appreciate that!

I tried that example - it is what I am using. I had to fiddle with the
placement of the databinds.

Of course now I have to get paging working and my select buttons on the
side are ignored!

Fix one thing - it leads to another issue!

Thanks for your time and help!

Tmuld

Nov 21 '05 #7
I mean sorting! Sorting is another strange animal.

And trying to make my BACK button work so it doesn't clear the grid
data and query. And of course asking the user to hit the 'back' button
on the browser is a "no go").

Tmuld

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2727
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update not the whole page, but a portion of the page. Strangely enough the URL below http://beta.asp.net/QUICKSTARTV20/aspnet/doc/ctrlref/data/gridview.aspx (VB GridView Paging and Sorting Callbacks example)
2
2216
by: asad | last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom paging bcoz data is too heavy so pls tell me how can i use custom paging in ASP.NET Thanks
1
7468
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update not the whole page, but a portion of the page. Strangely enough the URL below http://beta.asp.net/QUICKSTARTV20/aspnet/doc/ctrlref/data/gridview.aspx (VB GridView Paging and Sorting Callbacks example)
0
545
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update not the whole page, but a portion of the page. Strangely enough the URL below http://beta.asp.net/QUICKSTARTV20/aspnet/doc/ctrlref/data/gridview.aspx (VB GridView Paging and Sorting Callbacks example)
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.