Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.

F

Franck

Hello,
in a datagrid, in the ItemDataBound event
in some cells a add some javascript that show up an information

strHref.Append("<A onclick=\"popupValid();\">");
strHref.Append("<span style=\"cursor:pointer\">");
strHref.Append(e.Item.Cells[1].Text+"</span></A>");

e.Item.Cells[1].Text=strHref.ToString();


if I had this when i ask for the next page (i'm using paging)
i recieve the following error

"Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. "

even if the values are the following:

datagrid.currentpageindex=1
datagrid.pagecount=2

-----code----
dgNivCompart.DataSource=tblCompart.DefaultView;
dgNivCompart.CurrentPageIndex=intPageIndexGridNivCompart;
int huio=dgNivCompart.PageCount;
dgNivCompart.DataBind();
-----code----

if i had nothing it work wells....
Am I missing something?
 
F

Franck

Phillip said:
What does your Javascript function popupValid() do?

only showing a popup with some info
no update, nothing...

function popupValidation()
{
var PopupWindow=null;
settings='width=250,height=172'
PopupWindow=window.open('Validation.aspx?','Confirm',settings);
PopupWindow.focus();
}


-- HTH, Phillip Williams http://www.societopia.net
http://www.webswapp.com "Franck said:
Hello,
in a datagrid, in the ItemDataBound event
in some cells a add some javascript that show up an information

strHref.Append("<A onclick=\"popupValid();\">");
strHref.Append("<span style=\"cursor:pointer\">");
strHref.Append(e.Item.Cells[1].Text+"</span></A>");

e.Item.Cells[1].Text=strHref.ToString();


if I had this when i ask for the next page (i'm using paging)
i recieve the following error

"Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. "

even if the values are the following:

datagrid.currentpageindex=1
datagrid.pagecount=2

-----code----
dgNivCompart.DataSource=tblCompart.DefaultView;
dgNivCompart.CurrentPageIndex=intPageIndexGridNivCompart;
int huio=dgNivCompart.PageCount;
dgNivCompart.DataBind();
-----code----

if i had nothing it work wells....
Am I missing something?
 
G

Guest

Franck said:
only showing a popup with some info
no update, nothing...

function popupValidation()
{
var PopupWindow=null;
settings='width=250,height=172'
PopupWindow=window.open('Validation.aspx?','Confirm',settings);
PopupWindow.focus();
}

If your analysis were correct (namely that removing this javascript fixes
the problem) then the Validation.aspx must be doing something that changed
the datasource data (and thereby affecting the page count on the rendered
grid. If on the other hand, validation.aspx is innocent of this suspicion
then you probably should step through the code carefully using the debugger
to find another analysis of the cause of the problem. The error that you are
getting usually happens with me when I databind the datagrid to a new dataset
that has lesser page count than the CurrentPageIndex.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com "Franck said:
Hello,
in a datagrid, in the ItemDataBound event
in some cells a add some javascript that show up an information

strHref.Append("<A onclick=\"popupValid();\">");
strHref.Append("<span style=\"cursor:pointer\">");
strHref.Append(e.Item.Cells[1].Text+"</span></A>");

e.Item.Cells[1].Text=strHref.ToString();


if I had this when i ask for the next page (i'm using paging)
i recieve the following error

"Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. "

even if the values are the following:

datagrid.currentpageindex=1
datagrid.pagecount=2

-----code----
dgNivCompart.DataSource=tblCompart.DefaultView;
dgNivCompart.CurrentPageIndex=intPageIndexGridNivCompart;
int huio=dgNivCompart.PageCount;
dgNivCompart.DataBind();
-----code----

if i had nothing it work wells....
Am I missing something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top