Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Paging a datagrid

Reply
Thread Tools

Paging a datagrid

 
 
Fabiano
Guest
Posts: n/a
 
      11-27-2003
Please,

i've created a datagrid that allow numbered paging.
But when i click over a page that must be called, i get this error:

System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0
and < the PageCount

at my page, on Paging Event i'm using the commands bellow:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}



I get the error at the DataBind function. what could be wrong?



Tks

Fabiano


 
Reply With Quote
 
 
 
 
Michael Tkachev
Guest
Posts: n/a
 
      11-28-2003
hi,

This is a mistake because you don't fill datasourse in the datagrid!
You have to fill datagrid again after selected CurrentPageIndex.

For example:

DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataSourse = ...//Your sourse. and then you can make databind of
datagrid.
DataGrid1.DataBind();

bye-bye.

The Best Regards,
Web Developer
Michael Tkachev

"Fabiano" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Please,
>
> i've created a datagrid that allow numbered paging.
> But when i click over a page that must be called, i get this error:
>
> System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0
> and < the PageCount
>
> at my page, on Paging Event i'm using the commands bellow:
>
> private void DataGrid1_PageIndexChanged(object source,
> System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
> {
> DataGrid1.CurrentPageIndex = e.NewPageIndex;
> DataGrid1.DataBind();
> }
>
>
>
> I get the error at the DataBind function. what could be wrong?
>
>
>
> Tks
>
> Fabiano
>
>



 
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
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
datagrid , SQL Reader and Paging... Datagrid disappears Roger ASP .Net 0 12-28-2004 04:05 PM
DataSet paging vs Datareader paging =?Utf-8?B?UGF0cmljay5PLklnZQ==?= ASP .Net 1 10-08-2004 02:13 PM
Paging Dr. Who, Paging Dr. Who... Father_Sicko@TheOrphanage.com Computer Security 1 07-02-2004 08:59 PM



Advertisments