Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Sunday, December 2, 2012

List of fields in a list SharePoint programmatically:



Below post will help you to get the list of columns that is displayed when you view the items in the list programtically:

var fields = from SPField f in list.Fields
                    where !f.Hidden && f.AuthoringInfo == "" &&
                                  f.Type! = SPFieldType.Attachments &&
                                  f.Title! = "SharingID" &&
                                  f.Type! = SPFieldType.WorkflowStatus
                    orderby f.Title
                    select new { ListItem = new ListItem(f.Title, f.Id.ToString()),
                                Readonly = f.ReadOnlyField, FieldType = f.Type };



 Note: we will get the null result to the “f.AuthoringInfo” in SharePoint 2007 but we can get string empty result to the “f.AuthoringInfo” in SharePoint 2010.
 So, use: f.AuthoringInfo == null [In SP2007] & f.AuthoringInfo == ""[In SP2010]

Output: We can get the list of viewable lists by default once create a sample list in SharePoint.


    

No comments:

Post a Comment