473,480 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGrid Paging doesnt page!

Dee
Hi
The paging numbers of my DataGrid dont actually page. What can be the cause?
Everyting else seems to work.
Thanks
Dee
Nov 19 '05 #1
6 1433
What code have you entered into the PageIndexChanged event handler?
"Dee" <dee@home> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi
The paging numbers of my DataGrid dont actually page. What can be the
cause?
Everyting else seems to work.
Thanks
Dee

Nov 19 '05 #2
Dee
Thanks Scott,
I dodnt know I needd to handle that event.
It workd now. I added:

DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()

It's intersting that the paging works without thr DataBind() call but have
to click on the page TWICE!
"Scott M." <s-***@nospam.nospam> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
What code have you entered into the PageIndexChanged event handler?
"Dee" <dee@home> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi
The paging numbers of my DataGrid dont actually page. What can be the
cause?
Everyting else seems to work.
Thanks
Dee


Nov 19 '05 #3
HI
set the property of datagrid to AllowPaging="True"
then
on the grid_page index changed event
write the code

grid.CurrentPageIndex = e.NewPageIndex ;

and then write the code for connecting to the datbase
"Dee" <dee@home> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi
The paging numbers of my DataGrid dont actually page. What can be the cause?
Everyting else seems to work.
Thanks
Dee

Nov 19 '05 #4
You must ALWAYS call the databind method after making any kind of change to
the datagrid that affects what data the grid is showing.

The reason you'd have to click the pager twice without the extra databind
call is that the grid uses ViewState to remember, not only the data that is
was showing, but also other "state" information such as what page of data
was showing, what sort order was in effect, what row was being edited or was
selected, etc.

Without the databind call, the grid is bound to its data in Page_Load
(that's where you do have a databind call, right?) and the first click sets
the page correctly but doesn't update the grid with the new page of data
because no databind call took place AFTER setting the page to show, the
second click causes the grid to bind to its data in Page_Load as well, but
now the grid is "remembering" via ViewState what page of data to display
BEFORE the databind call takes place.

In general, your page load event handler should look like this:

datagrid.datasource = someDataSource
If Not IsPostBack Then
datagrid.databind
End If

and then at the end of EACH and EVERY datagrid event handler where the data
would change in some way (sortCommand, PageIndexChanged, EditCommand,
DeleteCommand, SortCommand, CancelCommand)

datagrid.databind

"Dee" <dee@home> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Thanks Scott,
I dodnt know I needd to handle that event.
It workd now. I added:

DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()

It's intersting that the paging works without thr DataBind() call but have
to click on the page TWICE!
"Scott M." <s-***@nospam.nospam> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
What code have you entered into the PageIndexChanged event handler?
"Dee" <dee@home> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi
> The paging numbers of my DataGrid dont actually page. What can be the
> cause?
> Everyting else seems to work.
> Thanks
> Dee
>
>



Nov 19 '05 #5
Dee
Wow
Great explanation! Thanks very much.
Dee

"Scott M." <s-***@nospam.nospam> wrote in message
news:#b**************@TK2MSFTNGP10.phx.gbl...
You must ALWAYS call the databind method after making any kind of change to the datagrid that affects what data the grid is showing.

The reason you'd have to click the pager twice without the extra databind
call is that the grid uses ViewState to remember, not only the data that is was showing, but also other "state" information such as what page of data
was showing, what sort order was in effect, what row was being edited or was selected, etc.

Without the databind call, the grid is bound to its data in Page_Load
(that's where you do have a databind call, right?) and the first click sets the page correctly but doesn't update the grid with the new page of data
because no databind call took place AFTER setting the page to show, the
second click causes the grid to bind to its data in Page_Load as well, but
now the grid is "remembering" via ViewState what page of data to display
BEFORE the databind call takes place.

In general, your page load event handler should look like this:

datagrid.datasource = someDataSource
If Not IsPostBack Then
datagrid.databind
End If

and then at the end of EACH and EVERY datagrid event handler where the data would change in some way (sortCommand, PageIndexChanged, EditCommand,
DeleteCommand, SortCommand, CancelCommand)

datagrid.databind

"Dee" <dee@home> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Thanks Scott,
I dodnt know I needd to handle that event.
It workd now. I added:

DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()

It's intersting that the paging works without thr DataBind() call but have to click on the page TWICE!
"Scott M." <s-***@nospam.nospam> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
What code have you entered into the PageIndexChanged event handler?
"Dee" <dee@home> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi
> The paging numbers of my DataGrid dont actually page. What can be the
> cause?
> Everyting else seems to work.
> Thanks
> Dee
>
>



Nov 19 '05 #6
No problem. Good luck.
"Dee" <dee@home> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Wow
Great explanation! Thanks very much.
Dee

"Scott M." <s-***@nospam.nospam> wrote in message
news:#b**************@TK2MSFTNGP10.phx.gbl...
You must ALWAYS call the databind method after making any kind of change

to
the datagrid that affects what data the grid is showing.

The reason you'd have to click the pager twice without the extra databind
call is that the grid uses ViewState to remember, not only the data that

is
was showing, but also other "state" information such as what page of data
was showing, what sort order was in effect, what row was being edited or

was
selected, etc.

Without the databind call, the grid is bound to its data in Page_Load
(that's where you do have a databind call, right?) and the first click

sets
the page correctly but doesn't update the grid with the new page of data
because no databind call took place AFTER setting the page to show, the
second click causes the grid to bind to its data in Page_Load as well,
but
now the grid is "remembering" via ViewState what page of data to display
BEFORE the databind call takes place.

In general, your page load event handler should look like this:

datagrid.datasource = someDataSource
If Not IsPostBack Then
datagrid.databind
End If

and then at the end of EACH and EVERY datagrid event handler where the

data
would change in some way (sortCommand, PageIndexChanged, EditCommand,
DeleteCommand, SortCommand, CancelCommand)

datagrid.databind

"Dee" <dee@home> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
> Thanks Scott,
> I dodnt know I needd to handle that event.
> It workd now. I added:
>
> DataGrid1.CurrentPageIndex = e.NewPageIndex
> DataGrid1.DataBind()
>
> It's intersting that the paging works without thr DataBind() call but have > to click on the page TWICE!
>
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:ui**************@TK2MSFTNGP09.phx.gbl...
>> What code have you entered into the PageIndexChanged event handler?
>>
>>
>> "Dee" <dee@home> wrote in message
>> news:%2****************@TK2MSFTNGP09.phx.gbl...
>> > Hi
>> > The paging numbers of my DataGrid dont actually page. What can be
>> > the
>> > cause?
>> > Everyting else seems to work.
>> > Thanks
>> > Dee
>> >
>> >
>>
>>
>
>



Nov 19 '05 #7

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

Similar topics

1
2219
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). This code doesn't even run unless a button in...
2
3552
by: RelaxoRy | last post by:
sqlConnection1.Open(); myReader = sqlCommand1.ExecuteReader(); DataGrid1.DataSource = myReader; DataGrid1.DataBind(); myReader.Close(); sqlConnection1.Close(); The Datagrid populates fine. ...
3
8669
by: Joseph D. DeJohn | last post by:
I am trying to get pagination working on a datagrid. Can anyone point me to a resource for help on this? I'm not sure if custom paging is the best option or not.
2
2221
by: enak | last post by:
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...
2
2561
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has...
0
1835
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). I have tried a few different notations...
6
1791
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP...
5
2750
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
3
1810
by: Pat | last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i populate the Child databrid using myDataGrid.SelectedIndex value as the filter and setting the DataKeyField. I enabled...
0
7037
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,...
0
7080
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5326
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,...
0
4476
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...
0
2992
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1296
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 ...
0
176
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...

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.