页面索引无法在gridview中工作

时间:2014-02-12 12:47:03

标签: c# asp.net gridview sharepoint-2010 sharepoint-2007

此处无法在网格视图中处理页面索引。 请给我一些建议。

protected void grid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    //grid.PageIndex = e.NewPageIndex;

    grid.PageIndex = e.NewPageIndex;

    SPSite mysite = SPContext.Current.Site;
    SPWeb website = mysite.OpenWeb();
    SPListCollection collection = website.Lists;
    foreach (SPList lst in collection)
    {
        if (lst.BaseTemplate.ToString() == "DiscussionBoard")
        {
            //SPListItemCollection itemcoll = lst.GetItems();

            SPQuery qrydlist = new SPQuery();
            qrydlist.ViewAttributes += " Scope=\"RecursiveAll\"";
            qrydlist.Query = "<OrderBy><FieldRef Name=\"ID\" /></OrderBy>";
            SPListItemCollection items = lst.GetItems(qrydlist);

            DataTable dt = items.GetDataTable();

            foreach (SPListItem item in items)
            {

                DataRow dtrow = DisscussionBoardDataTable.NewRow();
                // string itemUrl = (SPContext.Current.Site.Url + list.DefaultDisplayFormUrl.ToString() + "?ID=" + drow["ID"]).Replace(" ", "%20") + "&Source=" + HttpContext.Current.Request.Url.ToString();

                dtrow["itemUrl"] = item.ParentList.ParentWebUrl + "/" + item.Url;
                dtrow["LinkDiscussionTitle"] = item["LinkDiscussionTitle"];
                string createdby = item["Author"].ToString();
                string[] createdsplit = createdby.Split('#');
                string createdname = createdsplit[1].ToString();
                dtrow["Author"] = createdname;
                //dtrow["Author"] = item["Author"];
                DateTime dt123 = Convert.ToDateTime(item["Created"]);
                var dddd = dt123.ToShortDateString();
                dtrow["Created"] = dddd;
                //  lblReslt.Text += item["Author"] + "__" + item.Url;
                DisscussionBoardDataTable.Rows.Add(dtrow);

            }
            //Binding the images to the repeater control
            //grid.DataSource = dt;
            grid.DataSource = DisscussionBoardDataTable;
            grid.DataBind();

        }
    }
}

0 个答案:

没有答案