It’s
a very common programming practice to check our newly created list already
exists in the specified web or not? Below code will help you on this scenario.
Before adding column(field) to the specified list it’s better to check whether that lists exists or not and new created field already exists or not? In my code, I am checking all these conditions.
Refer Also:
Before adding column(field) to the specified list it’s better to check whether that lists exists or not and new created field already exists or not? In my code, I am checking all these conditions.
Refer Also:
- How to create a list programmatically?
- How to check if the lists exits ornot?
- How to check if the list templateexists or not?
- Error handling technique:
////// FUNCTION : IsListExists /// PURPOSE : Checking whether the List exists in the mentioned Web or not /// PARAMETERS : currentWeb -> current web /// strListName-> A string containing the list name /// RETURNS : The result as a boolean /// ----------------------------------------------------------------------- /// public static bool IsListExists(string strListName, SPWeb currentWeb) { bool isListExists = false; try { using (currentWeb) { isListExists = currentWeb.Lists.Cast().Any(list => string.Compare(list.Title, strListName, true) == 0); } } catch (Exception ex) { //Error hadling code } return isListExists; } //
No comments:
Post a Comment