1. 현재 페이지 번호 가져오기

protected void ListView1_OnPagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
	int currentPage = (e.StartRowIndex / e.MaximumRows) + 1;
}
혹은
protected void ListView1_OnDataBound(object sender, EventArgs e)
{
	int currentPage = (DataPager1.StartRowIndex / DataPager1.MaximumRows) + 1;
}

2. 보여지는 전체 갯수

GoodsView.Items.Count

3. 전체 게시물의 갯수

protected void ListView1_OnDataBound(object sender, EventArgs e)
{
	//ListView.DataBind()가 실행될 때 지정된다
	DataPager1.TotalRowCount
}

4. 전체 페이지 갯수

protected void ListView1_OnDataBound(object sender, EventArgs e)
{
	int pageCount = DataPager1.TotalRowCount / DataPager1.PageSize;
	if (pageCount * DataPager1.PageSize != DataPager1.TotalRowCount)
	{
		pageCount += 1;
	}
}

5. ROW 갯수 기준으로 아이템 번호 표시하기

Goods.aspx.cs :
namespace web.test
{
	public partial class Goods : System.Web.UI.Page
	{
		private int _currentGoodsIdx = 0;
		protected int CurrentGoodsIdx
		{
			get
			{
				return _currentGoodsIdx--;
			}
		}

		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void GoodsPager_OnPreRender(object sender, EventArgs e)
		{
			int currentPage = (GoodsPager.StartRowIndex / GoodsPager.MaximumRows) + 1;
			_currentGoodsIdx = GoodsPager.TotalRowCount - (GoodsPager.PageSize * (currentPage - 1));
		}
	}
}

Goods.aspx :
<%@ Page Title="" Language="C#" MasterPageFile="/web.test/main/Admin.Master" AutoEventWireup="true" CodeBehind="Goods.aspx.cs" Inherits="web.test.goods.Goods" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
	<asp:ObjectDataSource ID="GoodsDataSource" runat="server" TypeName="layer.biz.GoodsBiz"
		DataObjectTypeName="layer.biz.GoodsBiz" EnablePaging="true" SelectCountMethod="GetGoodsListCountForAdmin"
		SelectMethod="GetGoodsListForAdmin" StartRowIndexParameterName="startRowIndex" MaximumRowsParameterName="maximumRows" />
	<asp:ListView ID="GoodsView" runat="server" DataSourceID="GoodsDataSource" DataKeyNames="GIdx">
		<LayoutTemplate>
			<table>
				<asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
			</table>
		</LayoutTemplate>
		<ItemTemplate>
			<tr>
				<td><%= CurrentGoodsIdx %></td>
				<td><%#Eval("GName") %></td>
			</tr>
		</ItemTemplate>
	</asp:ListView>
	<asp:DataPager ID="GoodsPager" runat="server" PagedControlID="GoodsView" PageSize="10"
		OnPreRender="GoodsPager_OnPreRender">
		<Fields>
			<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
		</Fields>
	</asp:DataPager>
</asp:Content>

powered by Moniwiki | themed by clockoon
last modified 2010-07-02 00:20:36
Processing time 0.0086 sec