Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > strange Invalid CurrentPageIndex value

Reply
Thread Tools

strange Invalid CurrentPageIndex value

 
 
Daniel Bauke
Guest
Posts: n/a
 
      11-17-2003
i cannot find the rule why from time to time i'm receiving "Invalid
CurrentPageIndex value. It must be >= 0 and < the PageCount."

at the beginning it looked like it was something with weird browsers, but
looks like it's not a rule.

i suppose it started failing when i added:

protected void SearchResultsItemCreated(Object sender,
DataGridItemEventArgs e) {
DataGridItem item = e.Item;
if (item.ItemType == ListItemType.Pager) {
TableCell pager = (TableCell) item.Controls[0];
for (int i=0; i < pager.Controls.Count; i++) {
Control ctl = pager.Controls[i];
if (ctl is LinkButton) {
LinkButton lnk = (LinkButton) ctl;
lnk.CssClass = "navPage";
}

}
}
}

as a method for OnItemCreated.

stack trace of the error follows:

System.Web.HttpUnhandledException: Exception of type
System.Web.HttpUnhandledException was thrown. --->
System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0
and < the PageCount.
at System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource)
at System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e)
at System.Web.UI.WebControls.BaseDataList.DataBind()
at PB.Portal.Site.Portlets.Common.Search.SearchResult sBind()
at
PB.Portal.Site.Portlets.Common.Search.SearchResult s_PageIndexChanged(Object
source, DataGridPageChangedEventArgs e)
at
System.Web.UI.WebControls.DataGrid.OnPageIndexChan ged(DataGridPageChangedE
ventArgs e)
at System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source,
EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source,
EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)
at
System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.R
aisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
at System.Web.UI.Page.ProcessRequestMain()
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication+IExecutionS
tep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)

--------

on PageIndexChanged i have simple:

private void SearchResults_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e) {
SearchResults.CurrentPageIndex = e.NewPageIndex;
SearchResultsBind();
}

and SearchResultsBind() does:

private void SearchResultsBind() {
SearchResults.PageSize = ResultsPerPage;
DataSet sr = SqlResult;
if (sr.Tables.Count > 0) {
DataView dv = sr.Tables[0].DefaultView;
dv.Sort = OrderBy;
SearchResults.DataSource = dv;
SearchResults.DataBind();
}
// ...
}


and.. i have no idea what it is..


--
Daniel Bauke; http://www.bonkey.pl.eu.org; {happiness==bike&&unix;}
 
Reply With Quote
 
 
 
 
Alvin
Guest
Posts: n/a
 
      11-17-2003
It's annoying isn't it? It's a bug (undocumented). I have seen it happen
mostly when you use paging select an item on one page and change the
datagrid so that this item on that particular page no longer exists. I've
gotten so fed up of it that I just put a catch block around the bind code
and reset the pageindex = 0;

catch(Exception)

{

//reset and hope for the best here tehehehe

BaseReport.CurrentPageIndex = 0;

BaseReport.DataSource = ds;

BaseReport.DataBind();

}


--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Daniel Bauke" <(E-Mail Removed)> wrote in message
news:vxxojmbrul63.3mkqq6q5106v$(E-Mail Removed)...
> i cannot find the rule why from time to time i'm receiving "Invalid
> CurrentPageIndex value. It must be >= 0 and < the PageCount."
>
> at the beginning it looked like it was something with weird browsers, but
> looks like it's not a rule.
>
> i suppose it started failing when i added:
>
> protected void SearchResultsItemCreated(Object sender,
> DataGridItemEventArgs e) {
> DataGridItem item = e.Item;
> if (item.ItemType == ListItemType.Pager) {
> TableCell pager = (TableCell) item.Controls[0];
> for (int i=0; i < pager.Controls.Count; i++) {
> Control ctl = pager.Controls[i];
> if (ctl is LinkButton) {
> LinkButton lnk = (LinkButton) ctl;
> lnk.CssClass = "navPage";
> }
>
> }
> }
> }
>
> as a method for OnItemCreated.
>
> stack trace of the error follows:
>
> System.Web.HttpUnhandledException: Exception of type
> System.Web.HttpUnhandledException was thrown. --->
> System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0
> and < the PageCount.
> at System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
> useDataSource)
> at System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e)
> at System.Web.UI.WebControls.BaseDataList.DataBind()
> at PB.Portal.Site.Portlets.Common.Search.SearchResult sBind()
> at
>

PB.Portal.Site.Portlets.Common.Search.SearchResult s_PageIndexChanged(Object
> source, DataGridPageChangedEventArgs e)
> at
> System.Web.UI.WebControls.DataGrid.OnPageIndexChan ged(DataGridPageChangedE
> ventArgs e)
> at System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source,
> EventArgs e)
> at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs

args)
> at System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source,
> EventArgs e)
> at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs

args)
> at System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)
> at
> System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.R
> aisePostBackEvent(String eventArgument)
> at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument)
> at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
> at System.Web.UI.Page.ProcessRequestMain()
> --- End of inner exception stack trace ---
> at System.Web.UI.Page.HandleError(Exception e)
> at System.Web.UI.Page.ProcessRequestMain()
> at System.Web.UI.Page.ProcessRequest()
> at System.Web.UI.Page.ProcessRequest(HttpContext context)
> at
> System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication+IExecutionS
> tep.Execute()
> at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
> completedSynchronously)
>
> --------
>
> on PageIndexChanged i have simple:
>
> private void SearchResults_PageIndexChanged(object source,
> System.Web.UI.WebControls.DataGridPageChangedEvent Args e) {
> SearchResults.CurrentPageIndex = e.NewPageIndex;
> SearchResultsBind();
> }
>
> and SearchResultsBind() does:
>
> private void SearchResultsBind() {
> SearchResults.PageSize = ResultsPerPage;
> DataSet sr = SqlResult;
> if (sr.Tables.Count > 0) {
> DataView dv = sr.Tables[0].DefaultView;
> dv.Sort = OrderBy;
> SearchResults.DataSource = dv;
> SearchResults.DataBind();
> }
> // ...
> }
>
>
> and.. i have no idea what it is..
>
>
> --
> Daniel Bauke; http://www.bonkey.pl.eu.org; {happiness==bike&&unix;}



 
Reply With Quote
 
 
 
 
Daniel Bauke
Guest
Posts: n/a
 
      11-17-2003
On Mon, 17 Nov 2003 15:34:38 -0600, Alvin wrote:

> It's annoying isn't it? It's a bug (undocumented). I have seen it happen
> mostly when you use paging select an item on one page and change the
> datagrid so that this item on that particular page no longer exists. I've
> gotten so fed up of it that I just put a catch block around the bind code
> and reset the pageindex = 0;


well.. i'try to fix it that way. but

it's not the first time i need to kick something to make it work.. e.g. the
latest.. why on earth i get 'Arithmetic overflow error converting
expression to data type int' about once per 10k queries.. 8-o
and what is the only solution i found? try .. catch

--
Daniel Bauke; http://www.bonkey.pl.eu.org; {happiness==bike&&unix;}
 
Reply With Quote
 
Alvin Bruney
Guest
Posts: n/a
 
      11-18-2003
> latest.. why on earth i get 'Arithmetic overflow error converting
> expression to data type int' about once per 10k queries.. 8-o
> and what is the only solution i found? try .. catch


actually there was a patch out for this one, but i forget how long ago and
where the patch is.

--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Daniel Bauke" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Mon, 17 Nov 2003 15:34:38 -0600, Alvin wrote:
>
> > It's annoying isn't it? It's a bug (undocumented). I have seen it happen
> > mostly when you use paging select an item on one page and change the
> > datagrid so that this item on that particular page no longer exists.

I've
> > gotten so fed up of it that I just put a catch block around the bind

code
> > and reset the pageindex = 0;

>
> well.. i'try to fix it that way. but
>
> it's not the first time i need to kick something to make it work.. e.g.

the
> latest.. why on earth i get 'Arithmetic overflow error converting
> expression to data type int' about once per 10k queries.. 8-o
> and what is the only solution i found? try .. catch
>
> --
> Daniel Bauke; http://www.bonkey.pl.eu.org; {happiness==bike&&unix;}



 
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
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount in asp.net yakoobismail Software 0 05-22-2009 05:24 AM
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. Franck ASP .Net 4 06-29-2007 04:22 AM
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. George Smith ASP .Net 2 04-27-2007 12:05 AM
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCoun Juan G. ASP .Net Datagrid Control 5 07-12-2005 02:24 PM
Invalid CurrentPageIndex value jm ASP .Net 0 10-30-2003 10:42 PM



Advertisments