Problem with Top And Bottom Paging

R

rhungund

Hey guys and gals, I have a paging problem. I have my datagrid paging
set to Top and Bottom. And for some reason, when I click next on the
bottom pager, it goes back to page one. If I set it to only bottom,
same problem. If i set it to top, it works fine. Any ideas?

here's the code:
<asp:datagrid id="dg" runat="server" EnableViewState="true"
OnSortCommand="dg_SortCommand" AllowSorting="True"
OnPageIndexChanged="dg_Page" PagerStyle-CssClass="body"
PagerStyle-PrevPageText="< Previous"
PagerStyle-NextPageText="Next >" PagerStyle-HorizontalAlign="left"
PagerStyle-Mode="NumericPages"
PagerStyle-Position=TopAndBottom PageSize="10" AllowPaging="True"
GridLines="Both" Width="960"
CellSpacing="2" CellPadding="2" BorderWidth="0">
<HeaderStyle CssClass="" ForeColor="#ffffff"
VerticalAlign="Top"></HeaderStyle>
<ItemStyle CssClass="body"></ItemStyle>
<Columns>
<asp:BoundColumn Visible="false"></asp:BoundColumn>
</Columns>
</asp:datagrid>

And code behind:
Sub dg_Page(ByVal sender As Object, ByVal e As
DataGridPageChangedEventArgs)
dg.CurrentPageIndex = e.NewPageIndex
dg.EditItemIndex = -1
If Session("srt") <> "" Then
myDataBind(Session("srt"), "")
Else
myDataBind("Study ID", "")
End If
End Sub
 
A

ajamrozek

Are you calling the myDataBind() Sub on every Page_Load or Page_Init?
I'm pretty sure this needs to happen. I'm having some problems with
the pager on my datagrid at the moment too. But I've got my top and
bottom pagers working the same way. I am binding on every page_init
and in the pageindexchanged event. There are times when this is
redundant, but the pageindexchanged event isn't always called. I'm not
too sure of the technicalities of this, but I know that if I don't bind
in the page_load or _init, my datagrid doesn't work right. Though it's
not working right now, but the issue you're describing isn't happening
with mine.
HTH
 
R

rhungund

yep...calling myDataBind() everytime. just so weird because it works
for the top one, and not the bottom ones. here's what the javascript
pager links are looking like though.

top --> javascript:__doPostBack('dg$_ctl1$_ctl1','')
bottom --> javascript:__doPostBack('dg$_ctl15$_ctl1','')
 
A

ajamrozek

well the linkbuttons themselves and the javascript for them is gen'd at
runtime by the framework, and you can't touch those anyway (as far as I
know).
Try playing the enableviewstate attribute of your datagrid. I removed
my viewstate and had some things happen the way I wanted.
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top