Programmatically getting SharePoint Site Columns

Here is a simple code snippet of how to get all the available Site Columns under a given site.


public string GetSiteColumns(string site)
{
string sRet = string.Empty;
using (SPSite oSPSite = new SPSite(site))
{
using (SPWeb oSPWeb = oSPSite.OpenWeb())
{
foreach (SPField field in oSPWeb.Fields)
{
if(null == field) return null;

//if(field.Group.ToLower() == "srini")
//{
sRet += field.Title.ToString() + ",";
//}
}
}
}
return sRet;
}

Comments