码迷,mamicode.com
首页 > Web开发 > 详细

Sharepoint Webpart 自定义属性

时间:2014-04-29 10:22:47      阅读:435      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   os   

 

  

mamicode.com,码迷
namespace Webpart.Staffing.ViewAll
{
    [ToolboxItemAttribute(false)]
    public partial class ViewAll : WebPart
    {
        public ViewAll()
        {
        }

        private string _listName;
        [Personalizable(true)]
        [WebBrowsable(true)]
        [Category("Customize")]
        [WebDisplayName("List Name")]
        public string ListName
        {
            set { _listName = value; }
            get { return _listName; }
        }

        private DataTable GetItems()
        {
            SPListItemCollection collJD = null;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists.TryGetList(string.IsNullOrEmpty(_listName) ? HRConstant.listJDReferral : _listName);
                        SPQuery query = new SPQuery();
                        //query.Query=string.Format("<Where><And><Contains><FieldRef Name=\"Title\" /><Value Type=\"Text\">{0}</Value></Contains><And><Eq><FieldRef Name=\"Job_Location\" /><Value Type=\"Choice\">{1}</Value></Eq><And><Eq><FieldRef Name=\"Level\" /><Value Type=\"Choice\">{2}</Value></Eq><Contains><FieldRef Name=\"Job_Department\" /><Value Type=\"Text\">{3}</Value></Contains></And></And></And></Where>",positionTitle,location,positionLevel,department);
                        query.Query = string.Format("<Where><Eq><FieldRef Name=\"Status\" /><Value Type=\"Choice\">Open</Value></Eq></Where>");
                        query.ViewFields = "<FieldRef Name=\"Level\" /><FieldRef Name=\"Job_Location\" /><FieldRef Name=\"Title\" /><FieldRef Name=\"Job_Department\" />";
                        collJD = list.GetItems(query);
                    }

                }
            });
        }
    }
}    
mamicode.com,码迷

 

Sharepoint Webpart 自定义属性,码迷,mamicode.com

Sharepoint Webpart 自定义属性

标签:style   blog   http   java   color   os   

原文地址:http://www.cnblogs.com/batter152/p/3698632.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!