Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp.net DataGrid with DropDownList error

Status
Not open for further replies.

mariacri11

Programmer
Apr 9, 2003
22
0
0
CY
I have a page wich does the following:
I select a value from a DropDownList and I press a button.
The DataGrid displays values based on the selected value.

It works fine until I select a value which shoult display less pages then the previous selection.

In this case I get the following error:

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

I tried to write code on the button so that i return to the first datagrid page before executing the databind.
But PageCount property is read only .

Thanks!


 
Maria,

In the event handler for your button, you should reset the current page index to 0 before re-binding your DataGrid:

// within your button event handler
DataGrid.CurrentPageIndex = 0;




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top