ASP.NET 기초 강의실

시삽: 레드플러스 님 
게시판 이동:
 제목 : 이전 10개 / 다음 10개 페이징 처리 메서드
글번호: 251
작성자: 레드플러스
작성일: 2008/07/07 오전 11:41:00
조회수: 5839
    //[!] 페이징 처리 메서드
    /// <param name="PageNo">몇번째 페이지</param>
    /// <param name="NumPage">총 페이지 수</param>
    private void AdvancedPaging(int PageNo, int NumPage)
    {
        ++PageNo;
        int i = 0;
        string strPage = "<!--이전 10개, 다음 10개 페이징 처리 시작--><font style=\"font-size: 9pt;\"><font color=\"#c0c0c0\">[</font>";
        if (PageNo > 10)
        {
            strPage += "<a href=\"" + Request.ServerVariables["SCRIPT_NAME"] + "?Page=" + Convert.ToString(((PageNo - 1) / (int)10) * 10) + "\">◀</a>";
        }
        else
        {
            strPage += "<font color=\"#c0c0c0\">◁</font>";
        }

        strPage += "<font color=\"#c0c0c0\">|</font>";

        for (i = (((PageNo - 1) / (int)10) * 10 + 1); i <= ((((PageNo - 1) / (int)10) + 1) * 10); i++)
        {
            if (i > NumPage)
            {
                break;
            }
            if (i == PageNo)
            {
                strPage += "<b>" + i.ToString() + "</b> <font color=\"#c0c0c0\">|</font>";
            }
            else
            {
                strPage += "<a href=\"" + Request.ServerVariables["SCRIPT_NAME"] + "?Page=" + i.ToString() + "\">" + i.ToString() + "</a> <font color=\"#c0c0c0\">|</font>";
            }
        }

        if (i < NumPage)
        {
            strPage += "<a href=\"" + Request.ServerVariables["SCRIPT_NAME"] + "?Page=" + Convert.ToString(((PageNo - 1) / (int)10) * 10 + 11) + "\">▶</a>";
        }
        else
        {
            strPage += "<font color=\"#c0c0c0\">▷</font>";
        }

        strPage += "<font color=\"#c0c0c0\">]</font></font><!--이전 10개, 다음 10개 페이징 처리 종료-->";

        ctlAdvancedPaingList.Text = strPage;
        #region 코드 설명
        //++PageNo; // 페이지 번호 1증가 : 0번째 페이지 -> 1페이지로 표시
        //string strPage = "";
        ////[1] 이전 10개 페이지
        //strPage += "<a href='"
        //    + Request.ServerVariables["SCRIPT_NAME"]
        //    + "?Page="
        //    + Convert.ToString(((PageNo - 1) / (int)10) * 10)
        //    + "'>이전10개</a>";
        ////[2] 다음 10개 페이지
        //strPage += "<a href='"
        //    + Request.ServerVariables["SCRIPT_NAME"]
        //    + "?Page="
        //    + Convert.ToString(((PageNo - 1) / (int)10) * 10 + 11)
        //    + "'>다음10개</a>";
        //#region 처음/마지막
        //////[A] [처음] 이동 링크
        ////if (PageNo != 1) {
        ////    strPage +=
        ////    "<a href=\"" + Request.ServerVariables["SCRIPT_NAME"]
        ////    + "?Page=1\">[처음]</a> ";
        ////}
        ////else {
        ////    strPage += "<span style='color:silver;'>[처음]</a>";
        ////}
        //////[B] [마지막] 이동 링크
        ////if (PageNo != NumPage) {
        ////    strPage +=
        ////    "<a href=\"" + Request.ServerVariables["SCRIPT_NAME"]
        ////    + "?Page=" + NumPage + "\">[마지막]</a> ";
        ////}
        ////else {
        ////    strPage += "<span style='color:silver;'>[마지막]</a>";
        ////}
        //#endregion
        ////[!] 최종 출력
        //ctlAdvancedPaingList.Text = strPage;
        #endregion
    }
 
이전 글   다음 글 삭제 수정 답변 글쓰기 리스트


관련 아티클 리스트
  제       목 파일 작성자 작성일 조회
이전글 [!] 기본형 게시판 만들기(Enterprise Library V4.X) : /Web... - 레드플러스 2008-07-07 7602
현재글 이전 10개 / 다음 10개 페이징 처리 메서드 - 레드플러스 2008-07-07 5839
다음글 [!] 일정관리 모듈 : /WebSchedule/Schedule/ - 레드플러스 2008-07-01 8175
 
손님 사용자 Anonymous (손님)
로그인 Home