dropdownlist分页

<div class="new-paging" id="">
            <div class="new-tbl-type">
                <div class="new-tbl-cell">
                    <a href="<%=prevurl %>" class="new-a-prve"><span>上一页</span></a>
                </div>
                <div class="new-tbl-cell new-p-re" id="pagelist">
                    <div class="new-a-page">
                        <span class="new-open">1/100</span>
                    </div>
                    <asp:DropDownList ID="pageselect" runat="server" class="new-select" onchange="combocg(this);">
                    </asp:DropDownList>
                </div>
                <div class="new-tbl-cell">
                    <a href="<%=nexturl %>" class="new-a-next"><span>下一页</span></a>
                </div>
            </div>
        </div>
 List<student"> list = null;
           	 List<student"> listst = null;
 		 SqlParameter[] parames = new SqlParameter[0]; 
		string selsql="select * from student";
     		DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.SqlConncectionString, CommandType.Text, selSql, parames);
		if (ds != null && ds.Tables[0].Rows.Count > 0)  
        	{  
           		rowsCount = ds.Tables[0].Rows.Count;
       		 }    
                if ((nowPage - 1) * pageSize > rowsCount) nowPage = 1;
                int takecount = rowsCount - (nowPage - 1) * pageSize;
                if (takecount > pageSize)
                    listst = list.Skip((nowPage - 1) * pageSize).Take(pageSize).ToList();
                else
                    listst = list.Skip((nowPage - 1) * pageSize).Take(takecount).ToList();
                foreach (var img in listst)
                {
                    img.C_IMGURL = img.C_IMGURL.Replace(".", "_130_140.");
                }
                pageselect.Items.Clear();
                int pagecount = rowsCount % pageSize > 0 ? rowsCount / pageSize + 1 : rowsCount / pageSize;
                for (int i = 0; i < pagecount; i++)
                {
                    pageselect.Items.Add(new ListItem("第" + (i + 1).ToString() + "页", (i + 1).ToString()));
                }
                rplist.DataSource = listst;
                rplist.DataBind();//绑定Repeater
                url = "/Web/Manage/fenye.aspx?";
                url += "&page=";
                prevurl = nowPage > 1 ? url + (nowPage - 1) : url + "1";
                nexturl = nowPage < pagecount ? url + (nowPage + 1) : url + nowPage;
                pageselect.SelectedValue = nowPage.ToString();

 

 

posted @ 2014-05-27 17:59  张三的编码生活  阅读(303)  评论(0编辑  收藏  举报