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>
<aspataPager runat="server" ID="DataPager" PageSize="3" >
<Fields>
<asp:NumericPagerField ButtonCount="5" PreviousPageText="<--"
NextPageText="-->" />
</Fields>
</aspataPager>
</LayoutTemplate>
<ItemTemplate>
<tr class=griditem>
<td class="griditemcolumn"><%# Eval("Id") %></td>
<td class="griditemcolumn"><%# Eval("Name") %></td>
</tr>
</ItemTemplate>
</asp: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>
<aspataPager runat="server" ID="DataPager" PageSize="3" >
<Fields>
<asp:NumericPagerField ButtonCount="5" PreviousPageText="<--"
NextPageText="-->" />
</Fields>
</aspataPager>
</LayoutTemplate>
<ItemTemplate>
<tr class=griditem>
<td class="griditemcolumn"><%# Eval("Id") %></td>
<td class="griditemcolumn"><%# Eval("Name") %></td>
</tr>
</ItemTemplate>
</asp:ListView>