Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SPList list = SPContext.Current.Web.Lists["my list name"];
- SPListItem item = list.items.GetItemById(ItemId);
- //the following 2 lines are not strictly necessary
- //but since you explicitly mentioned this is related to ContentTypes
- //this is how you can ensure the item you retrieved is of the apprpriate type
- SPContentTypeId myContentTypeId = GetContentTypeId();
- if (list.ContentTypes.BestMatch(myContentTypeId).Equals(item.ContentType.Id))
- {
- string value = item["interesting field name"].ToString();
- //if the value is of interest, do your thing
- }
- var item = SPContext.Current.File.Item; //returns the SPListItem for the current context
- var myField = item["SomeFieldName"]; //this will throw a NullReferenceException if there is no data for the field yet though
- Response.Write(myField.ToString());
Add Comment
Please, Sign In to add comment