0

在以下代码中,我试图在中继器顶部显示最新记录。我还想在转发器中包含分页。分页在页面中成功完成,但是当我在转发器中进行排序时遇到问题。所以我的问题是我如何在转发器中进行排序和分页?

我的代码:

private void Get_Data()
    {

        String File = Server.MapPath("~/Data/BlogContent.xml");
        DataSet ds = new DataSet();

        ds.ReadXml(File);

        DataView dv = new DataView(ds.Tables[0]);
        dv.Sort = "id DESC";
        DataTable dt = dv.Table;
        ViewState.Add("Mytable", dt);

    }
    private void Bind_Data(int take, int pageSize)
    {
        PagedDataSource page = new PagedDataSource();
        page.AllowCustomPaging = true;
        page.AllowPaging = true;
        DataTable dtv = (DataTable)ViewState["Mytable"];
        DataView dv = new DataView();
        dv = dtv.DefaultView;
        dv.Sort = "id ASC";
        dv.RowFilter = "id>=" + pageSize + " AND " + "id<=" + take;
        page.DataSource = dv;
        page.PageSize = psize;
        Repeater1.DataSource = page;
        Repeater1.DataBind();

        if (!IsPostBack)
        {
            int rowcount = dtv.Rows.Count;
            CreatePagingControl(rowcount);
        }

    } 
4

2 回答 2

0

** Read the article: Custom paging in Repeater control in asp.net(C#, VB)** http://www.webcodeexpert.com/2013/05/custom-paging-in-repeater-control-in.html

于 2013-07-26T11:21:05.533 回答
0

对于分页检查this.Here is full example of paging.link

分页和排序

于 2013-07-26T10:59:40.533 回答