예제 #1
0
        public List <ListFields> GetAllListColumns(string _siteName, string _listName)
        {
            List <ListFields> lsF = new List <ListFields>();

            using (SPSite site = new SPSite(_siteName))
            {
                using (web = site.OpenWeb())
                {
                    try
                    {
                        SPList list = web.Lists[_listName];
                        for (int i = 0; i < list.Fields.Count; i++)
                        {
                            ListFields ls = new ListFields();
                            ls.Title        = list.Fields[i].Title;
                            ls.InternalName = list.Fields[i].InternalName;
                            lsF.Add(ls);
                        }
                        SPQuery query = new SPQuery();
                        ///TO DO order by Create Date
                        query.Query = "<OrderBy><FieldRef Name=\"Order\" /></OrderBy>";
                        items       = list.GetItems(query);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }

            return(lsF);
        }
예제 #2
0
        public List<ListFields> GetAllListColumns(string _siteName , string _listName)
        {
            List<ListFields> lsF = new List<ListFields>();

            using (SPSite site = new SPSite(_siteName))
            {
                using (web = site.OpenWeb())
                {
                    try
                    {
                        SPList list = web.Lists[_listName];
                        for (int i = 0; i < list.Fields.Count; i++)
                        {
                            ListFields ls = new ListFields();
                            ls.Title = list.Fields[i].Title;
                            ls.InternalName = list.Fields[i].InternalName;
                            lsF.Add(ls);
                        }
                        SPQuery query = new SPQuery();
                        ///TO DO order by Create Date
                        query.Query = "<OrderBy><FieldRef Name=\"Order\" /></OrderBy>";
                        items = list.GetItems(query);

                    }
                    catch (Exception ex)
                    {

                        MessageBox.Show(ex.ToString());
                    }

                }

            }

            return lsF;
        }