public void Bind()
{
BLL.RoomBLL roomBLl = new BLL.RoomBLL();
// BLL.RoomBLL dal = new BLL.RoomBLL();
System.Collections.Generic.IList<Model.RoomInfo> room = roomBLl.GetRooms();
PagedDataSource objpds = new PagedDataSource();
objpds.DataSource = room;
objpds.AllowPaging = true;
objpds.PageSize = 6;
int CurPage;
string inputPage = TextBox2.Text;
int PageCount = room.Count / objpds.PageSize;
if (room.Count % objpds.PageSize > 0)
{
PageCount++;
}
if (Request.QueryString["Page"] != null)
{
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
}
else
{
CurPage = 1;
}
objpds.CurrentPageIndex = CurPage - 1;
lblCurrentPage.Text = "当前页:" + CurPage.ToString() + " 共" + PageCount.ToString() + "页";
LnkFirst.NavigateUrl = Request.CurrentExecutionFilePath;
if (!objpds.IsFirstPage)
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
if (!objpds.IsLastPage)
lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
LnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(PageCount);
lnkPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(inputPage);
DataList2.DataSource = objpds;
DataList2.DataBind();
}