ListView pagination problem.

G

George Ter-Saakov

Trying to quickly create paginated grid. So i am using ListView.
Unfortunatelly pagination works a little strange.
Pagination control appears correctly.

But when i click "2" page postback happens but current page is still first
page. Then i click "3" page. Postback happens but current page is now "2"
page. Then i click "4" page and again postback happens and page 3 becomes
current.

Why is that? How to make it work?
Bellow you can find my code (Nothing else like code or any other control is
on the page)

thanks
George.

-----------------
protected override void OnInit(EventArgs e)
{
if( !isPostBack )
{
grdItems.DataSource = clsGlobal.GetData("SELECT Id,Name FROM
tblMy");
grdItems.DataBind();
}
}
----------------------

<asp:ListView ID="grdItems" runat="server" DataKeyNames="ID">
<LayoutTemplate>
<table>
<tr class="gridheader">
<td class="gridheadercolumn">Id</td>
<td class="gridheadercolumn">Name</td>
</tr>
<tr runat="server" id="itemPlaceholder"></tr>
</table>
<asp:DataPager runat="server" ID="DataPager" PageSize="3" >
<Fields>
<asp:NumericPagerField ButtonCount="5" PreviousPageText="<--"
NextPageText="-->" />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr class=griditem>
<td class="griditemcolumn"><%# Eval("Id") %></td>
<td class="griditemcolumn"><%# Eval("Name") %></td>
</tr>
</ItemTemplate>
</asp:ListView>
 

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,808
Messages
2,569,686
Members
45,452
Latest member
AmberLayde

Latest Threads

Top