SPListTemplateCollection listColl = currentSite.GetCustomListTemplates(currentSite.RootWeb);
if (IsListTemplateExists(ListTemplateName, listColl )= true)
{
SPListTemplate listQuickLinksTemp = listColl [ListTemplateName];
CreateList(currentWeb, ListName, "Description of the list", listQuickLinksTemp);
}
Sub function:return true or false
public static bool IsListTemplateExists(string strListTemplateName, SPListTemplateCollection listTempColl)
{
bool isListTempExists = false;
try {
var temp = listTempColl.Cast().FirstOrDefault(x => x.Name.Equals(strListTemplateName));
if (temp != null)
isListTempExists = true;
}
catch (Exception ex)
{
}
return isListTempExists;
}
if (IsListTemplateExists(ListTemplateName, listColl )= true)
{
SPListTemplate listQuickLinksTemp = listColl [ListTemplateName];
CreateList(currentWeb, ListName, "Description of the list", listQuickLinksTemp);
}
Sub function:return true or false
public static bool IsListTemplateExists(string strListTemplateName, SPListTemplateCollection listTempColl)
{
bool isListTempExists = false;
try {
var temp = listTempColl.Cast().FirstOrDefault(x => x.Name.Equals(strListTemplateName));
if (temp != null)
isListTempExists = true;
}
catch (Exception ex)
{
}
return isListTempExists;
}
No comments:
Post a Comment