2
Answers

How to check particular List is Exists or not in SharePoint 2010 ?

Saravana Kumar S

Saravana Kumar S

12y
5.1k
1
How to check particular List is Exists or not in SharePoint 2010 ?

TryGetList method in SharePoint 2010


below is sample code.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Microsoft.SharePoint;
 
namespace MultiChoice
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://serverName/sites/Vijai/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists.TryGetList("Test");
                    if (list != null)
                    {
List is Exists 
                       
                    }
   else
   {
List Is not Exists 

   }
                }
            }
        }
    }
}

Answers (2)