I have a document library content type with multiple columns in Sharepoint2010. I would like to retrieve the values in the column by using the following code but fails.
objCurrentWeb = SPContext.Current.Web;
objList = objCurrentWeb.Lists["MyNewLists"];
foreach (SPListItem objListItem in objList.Items)
{
id = (objListItem["ApplicationId"]).toString();
}
How do I retrieve the values in my content type columns correctly?
Thank you!
It can fail in two cases: 1) There is no such a field "ApplicationId". Ensure you use field internal name 2) (objListItem["ApplicationId"]) is null, so it fails with NullReferenceException on casting to string.