Showing posts with label SPList. Show all posts
Showing posts with label SPList. Show all posts

Tuesday, June 24, 2008

SPList fields - parsing source-code

Here is the source-code to obtain an html table of fields for any list:

(Please note that this example takes place inside the Render(HtmlTextWriter writer) method:

using (SPSite site = new SPSite(SPContext.Current.Site.Url))

{

using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ServerRelativeUrl))

{

SPList list = web.Lists["YourList"];

SPListItemCollection iCol = list.Items;


writer.Write("<table border=\"1\">");

writer.Write("<tr><td><strong>Field name</strong></td><td><strong>Sample value (if any)</strong></td></tr>");

for (int i = 0; i < iCol[0].Fields.Count; i++)

{

writer.Write("<tr><td><strong>");

writer.Write(iCol[0].Fields[i].Title);

writer.Write("</strong><br/>" + iCol[0].Fields[i].Description);

writer.Write("</td><td>");

writer.Write(iCol[0].GetFormattedValue(iCol[0].Fields[i].Title));

writer.Write("</td></tr>");

}

writer.Write("</table>");

}

}


SPList fields

If you've ever worked with fields from a coding point of view in sharepoint 2007 or plan to do so, then this list is invaluable to you.

It contains all the default fields for a SPList item. (Remember that pages are essentially list items and the pages collection is essentially a list).

Field name Sample value (if any)
Content Type ID
0x0100E65E7B14B0BC434CB9F70A29DDD8C22E
Approver Comments

DocumentTitle
at work2.jpg
DocumentTitle
at work2.jpg
File Type

ID
3
Content Type
Item
Modified
6/24/2008 5:07 PM
Created
2/20/2008 1:41 AM
Created By
System Account
Modified By
System Account
Has Copy Destinations

Copy Source

owshiddenversion
2
Workflow Version
1
UI Version
512
Version
1.0
Attachments
False
Approval Status
Approved
Edit

Select
3
Instance ID

Order
300
GUID
{B16BDAD3-7279-4C90-890E-D64D4FF9FE6E}
Workflow Instance ID

URL Path
/corporate/divisions/officeoftheceo/capacitydepoloyment/agencies/Lists/BusinessPortalUploadRecord/3_.000
Path
corporate/divisions/officeoftheceo/capacitydepoloyment/agencies/Lists/BusinessPortalUploadRecord
Modified
6/24/2008 5:07 PM
Created
2/20/2008 1:41 AM
Item Type
0
Effective Permissions Mask
0x7fffffffffffffff
Name
3_.000
Unique Id
389a8e63-0d5d-42c8-b8dc-a3702f566496
ProgId

ScopeId
{8FF6C25F-7D37-4569-823F-4E1C2433F5CF}
HTML File Type

Edit Menu Table Start
3_.000
Edit Menu Table End
3
Name
3_.000
Name
3_.000
Type

Server Relative URL
/corporate/divisions/officeoftheceo/capacitydepoloyment/agencies/Lists/BusinessPortalUploadRecord/3_.000
Encoded Absolute URL
http://dvbmdas15:101/corporate/divisions/officeoftheceo/capacitydepoloyment/agencies/Lists/BusinessPortalUploadRecord/3_.000
File Name
3_
Property Bag

Level
1
Is Current Version
Yes


See next post for source-code on how to replicate this table.