List content type by group name
SPContentTypeCollection ctc=web.ContentTypes;
string id = string.Empty;
foreach (SPContentType item in ctc)
{
if (string.Equals(item.Group.ToStr开发者_开发百科ing(),"Custom CT"))
{
id = item.Id.ToString();
break;
}
Why is the id = item.id.tostring()
not working. Something's wrong in the if statement.
The code is fine. There was a misspelling for the CT group name that's why I wasn't getting all the content types for that group.
精彩评论