DataGrid, DropDownList and Paging

G

Guest

Hello -

Sorry to have posted this twice, but my question wasn't being answered and I
think it might be because my subject wasn't clear.

I have a datagrid and a dropdownlist (which is outside the datagrid). When
I click on a category in the dropdownlist, the datagrid changes to correspond
to that category. The datagrid is paged.

Everything works fine, as long as the pager is on the first page. When the
pager is not on the first page, I receive the following error: "Invalid
currentPageIndex value. It must be >= 0 and < PageCount."

What do I have to put in my code to "set" the pager to the value it has on
the first page? What is the way this is normally handled?

Any help will be greatly appreciated!
 
G

Guest

Thanks for your responses!

This is how it's paged:
<snip>
autogeneratecolumns="False"
onselectedindexchanged="dgPost_SelectedIndexChanged"
allowpaging="True" OnPageIndexChanged="NewPage" pagesize="10"
pagerstyle-position="Bottom" pagerstyle-mode="NextPrev"
pagerstyle-nextpagetext="Next >>" pagerstyle-prevpagetext="<< Prev"
pagerstyle-horizontalalign="Right" DataKeyField="PostID"
pagerstyle-height="20px">
<snip>

VB code for paging:
Sub NewPage(sender as Object, e As DataGridPageChangedEventArgs)
dgPost.CurrentPageIndex = e.NewPageIndex
FillPost
dgPost.DataBind
End Sub

[FillPost just fills the datagrid using a dataAdapter and stored procedure]

When "Next" is clicked in the dataGrid until you can't click anymore, and a
new item is selected in the dropdownlist, that's when I get the error. It
would seem to me if you could "reset" the value of "Next" to the first page
of the pager before anything else is done in the
dropdownlist_selectedIndexChanged, that may work, but I need to know what the
language is. I've tried dgPost.CurrentPageIndex = 1 and it didn't work.

Sandy
 
G

Guest

Sorry guys, for wasting your time. Just got the answer from Brock Allen in
my previous post. All I had to do was "reset" to zero, just as the error
code said. I'm having a brain problem, apparently . . .

Sandy
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top