Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Sunday, 22 June 2014

Add SharePoint List Items To C# List Programmatically

 private List<string> GetListItems()
        {
            //string[] ListArr = { string.Empty };
            List<string> list = null;
            try
            {
                SPList lst = Web.Lists["ListName"];
                SPListItemCollection lst_colls = lst.Items;
                if (lst_colls.Count > 0)
                {
                  
                    list = new List<string>();
                    foreach (SPListItem Item in lst_colls)
                    {
                        if (!string.IsNullOrEmpty(Convert.ToString(Item["Title"])))
                        {
                            list.Add(Convert.ToString(Item["Title"]));
                        }
                    }
                   
                }
                return list;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.