[[TableOfContents]]
=== 현재 페이지 번호 가져오기 ===
{{{
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;
}
}}}
=== 보여지는 전체 갯수 ===
{{{
GoodsView.Items.Count
}}}
=== 전체 게시물의 갯수 ===
{{{
protected void ListView1_OnDataBound(object sender, EventArgs e)
{
//ListView.DataBind()가 실행될 때 지정된다
DataPager1.TotalRowCount
}
}}}
=== 전체 페이지 갯수 ===
{{{
protected void ListView1_OnDataBound(object sender, EventArgs e)
{
int pageCount = DataPager1.TotalRowCount / DataPager1.PageSize;
if (pageCount * DataPager1.PageSize != DataPager1.TotalRowCount)
{
pageCount += 1;
}
}
}}}
=== 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" %>
<%= CurrentGoodsIdx %> |
<%#Eval("GName") %> |
}}}