• moss2010 仿内容查询部件代码


    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using System.Data;

    namespace  All_Tongzi.VisualWebPart1
    {
        public partial class VisualWebPart1UserControl : UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!this.IsPostBack)
                {
                    this.CheckBoxListTsta.Items.Clear();
                    using (SPSite site = SPContext.Current.Site)
                    {
                        foreach (SPWeb web in site.AllWebs)
                        {

                            foreach (SPList list in web.Lists)
                            {
                                if (list.BaseTemplate == SPListTemplateType.Announcements)
                                {
                                    foreach (SPListItem item in list.Items)
                                    {
                                        string vl = web.Title + " " + list.Title + " " + item["Title"].ToString();
                                        this.CheckBoxListTsta.Items.Add(vl);
                                    }
                                }
                            }
                        }
                    }

                    DataTable dtable = new DataTable();
                    dtable.Columns.Add(new DataColumn("Title"));
                    dtable.Columns.Add(new DataColumn("Score"));
                    dtable.Columns.Add(new DataColumn("Editor"));
                    dtable.Columns.Add(new DataColumn("Modified"));
                    dtable.Columns.Add(new DataColumn("url"));
                    using (SPSite site = SPContext.Current.Site)
                    {
                        foreach (SPWeb web in site.AllWebs)
                        {

                            foreach (SPList list in web.Lists)
                            {
                                if (list.BaseTemplate == SPListTemplateType.Announcements)
                                {
                                    foreach (SPListItem item in list.Items)
                                    {
                                        DataRow dr = dtable.NewRow();
                                        dr["Title"]=item["Title"].ToString();
                                        dr["Editor"] = item["Editor"].ToString().Split('#')[1].ToString();
                                        dr["Modified"] = item["FileRef"].ToString();
                                        dr["Score"] = web.Title;
                                        string url=site.Url+""+ item["FileRef"].ToString().Replace("1_.000","")+"DispForm.aspx?ID="+item["ID"].ToString();
                                        dr["url"] = url;
                                        //string vl = web.Title + " " + list.Title + " " + item["Title"].ToString();
                                        dtable.Rows.Add(dr);
                                    }
                                }
                            }
                        }
                    }
                    this.GridView1.DataSource = dtable;
                    this.GridView1.DataBind();
                }
            }
        }
    }

  • 相关阅读:
    2019杭电多校训练(一)
    2019牛客多校训练(二)
    2019牛客多校训练(一)
    codeforces#1196F. K-th Path(最短路,思维题)
    codeforces#1108E2. Array and Segments (线段树+扫描线)
    codeforces#1183F. Topforces Strikes Back(数论)
    SPOJ
    2020年4月 第十一届蓝桥杯大赛个人赛(软件类)省级模拟赛
    Codeforces Round #634 (Div. 3)
    POJ
  • 原文地址:https://www.cnblogs.com/IsNull/p/1794529.html
Copyright © 2020-2023  润新知