开发者

I need to list out the Custom list and library from SharePoint Site?

开发者 https://www.devze.com 2023-01-10 08:27 出处:网络
I need to list out the Custom list and library from SharePoint Sit开发者_开发知识库e? How to identify the content is comes under the custom created?This code will help you

I need to list out the Custom list and library from SharePoint Sit开发者_开发知识库e? How to identify the content is comes under the custom created?


This code will help you

     using (SPWeb web = currentSite.OpenWeb())
        {
            foreach (SPList list in web.Lists)
            {
                if (list.BaseType == SPBaseType.DocumentLibrary
                   &&
                list.BaseTemplate == SPListTemplateType.DocumentLibrary
                )
                {
               ListItem li = new ListItem();
                li.Text = list.Title;
                li.Value = list.ID.ToString();

                 }
                else if(list.BaseType == SPBaseType.GenericList
                    &&
                    list.BaseTemplate == SPListTemplateType.GenericList)
                {
                    ListItem li = new ListItem();
                    li.Text = list.Title;
                    li.Value = list.ID.ToString();

                }
            }
          }


Below code should help you

            SPList myList=SPContext.Current.Web.Lists["YourList"];
            if (myList.BaseType == SPBaseType.DocumentLibrary)
            {
                //My List is Document Library
            }

            if (myList.BaseType == SPBaseType.GenericList)
            {
                //My List is Custom List
            }
0

精彩评论

暂无评论...
验证码 换一张
取 消