您的位置:首页 > 移动开发 > Objective-C

List<T>的一个数据分页,对分页数据有帮助

2012-03-15 13:58 363 查看
       protected void Page_Load(object sender, EventArgs e)

        {

            int intPageRow = 6;//每页中的数据条数

            

            //有分页的现象

            List<MyFriend> lst = new List<MyFriend>();

            

            for (int m = 0; m < 13; m++)

            {

                MyFriend t = new MyFriend();

                t.IntRows = m;

                t.UserName = System.DateTime.Now.ToString()+"_"+m.ToString();

                lst.Add(t);

            }

            int intCount = lst.Count;

            int intPageCount;//分页页数

            //intPageRow为每页的数据数目

            if (intCount % intPageRow == 0)

            {

                intPageCount = intCount / intPageRow;

            }

            else

            {

                intPageCount = intCount / intPageRow + 1;

            }

            string[] arr = new string[intPageCount];

            for (int k = 0; k < intPageCount; k++)

            {

                

                int intBeginRecord = intPageRow*k;

                int intEndRecord = intPageRow * (k + 1);//要提取的记录数目

                if (intEndRecord > intCount)

                {

                    intEndRecord = intCount;

                }

                string strID = "";

                string strUserName = "";

                string[] arrCurrentPageData = new string[intPageRow];

                List<MyFriend> lstE = new List<MyFriend>();

                for (int m = intBeginRecord; m < intEndRecord; m++)

                {

                    //得到该页的数据

                    MyFriend tC = new MyFriend();

                    tC.IntRows = lst[m].IntRows;

                    tC.UserName = lst[m].UserName;

                    lstE.Add(tC);

                  

                    

                    

                }

                //这里可以将该List 处理你的业务逻辑 对lstE处理

            }

        }

        //

        //构造List

        private class MyFriend

        {

            private int intRows;

            private string userName;

          

            public int IntRows

            {

                set { intRows = value; }

                get { return intRows; }

            }

            public string UserName

            {

                set { userName = value; }

                get { return userName; }

            }

          

        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  list string object class
相关文章推荐