Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid Paging doesnt page!

Reply
Thread Tools

DataGrid Paging doesnt page!

 
 
Dee
Guest
Posts: n/a
 
      04-18-2005
Hi
The paging numbers of my DataGrid dont actually page. What can be the cause?
Everyting else seems to work.
Thanks
Dee


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      04-18-2005
What code have you entered into the PageIndexChanged event handler?


"Dee" <dee@home> wrote in message
news:%(E-Mail Removed)...
> Hi
> The paging numbers of my DataGrid dont actually page. What can be the
> cause?
> Everyting else seems to work.
> Thanks
> Dee
>
>



 
Reply With Quote
 
 
 
 
Dee
Guest
Posts: n/a
 
      04-18-2005
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." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What code have you entered into the PageIndexChanged event handler?
>
>
> "Dee" <dee@home> wrote in message
> news:%(E-Mail Removed)...
> > Hi
> > The paging numbers of my DataGrid dont actually page. What can be the
> > cause?
> > Everyting else seems to work.
> > Thanks
> > Dee
> >
> >

>
>



 
Reply With Quote
 
Jeebu
Guest
Posts: n/a
 
      04-18-2005
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:%(E-Mail Removed)...
> Hi
> The paging numbers of my DataGrid dont actually page. What can be the cause?
> Everyting else seems to work.
> Thanks
> Dee
>
>

 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      04-18-2005
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:%(E-Mail Removed)...
> 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." <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> What code have you entered into the PageIndexChanged event handler?
>>
>>
>> "Dee" <dee@home> wrote in message
>> news:%(E-Mail Removed)...
>> > Hi
>> > The paging numbers of my DataGrid dont actually page. What can be the
>> > cause?
>> > Everyting else seems to work.
>> > Thanks
>> > Dee
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Dee
Guest
Posts: n/a
 
      04-19-2005
Wow
Great explanation! Thanks very much.
Dee

"Scott M." <(E-Mail Removed)> wrote in message
news:#b$(E-Mail Removed)...
> 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:%(E-Mail Removed)...
> > 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." <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> What code have you entered into the PageIndexChanged event handler?
> >>
> >>
> >> "Dee" <dee@home> wrote in message
> >> news:%(E-Mail Removed)...
> >> > Hi
> >> > The paging numbers of my DataGrid dont actually page. What can be the
> >> > cause?
> >> > Everyting else seems to work.
> >> > Thanks
> >> > Dee
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      04-19-2005
No problem. Good luck.


"Dee" <dee@home> wrote in message
news:%(E-Mail Removed)...
> Wow
> Great explanation! Thanks very much.
> Dee
>
> "Scott M." <(E-Mail Removed)> wrote in message
> news:#b$(E-Mail Removed)...
>> 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:%(E-Mail Removed)...
>> > 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." <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >> What code have you entered into the PageIndexChanged event handler?
>> >>
>> >>
>> >> "Dee" <dee@home> wrote in message
>> >> news:%(E-Mail Removed)...
>> >> > Hi
>> >> > The paging numbers of my DataGrid dont actually page. What can be
>> >> > the
>> >> > cause?
>> >> > Everyting else seems to work.
>> >> > Thanks
>> >> > Dee
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sort list doesnt work, key=str still doesnt work notnorwegian@yahoo.se Python 3 05-27-2008 04:32 AM
PC doesnt boot first time and doesnt shutdown dann Computer Support 6 08-21-2006 07:31 AM
Combining numeric mode paging and nextPreview paging in datagrid Red ASP .Net 1 03-12-2005 11:41 PM
datagrid paging - customising paging style wh1974 ASP .Net 0 01-12-2005 03:48 PM
DataSet paging vs Datareader paging =?Utf-8?B?UGF0cmljay5PLklnZQ==?= ASP .Net 1 10-08-2004 02:13 PM



Advertisments