Sharepoint Webpart 自定义属性

时间:2014-04-29 10:22:47   收藏:0   阅读:435
 

  

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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!