kamagra how much to take

Determine If SharePoint List Column Exists In C#

This method is helpful if you need to determine whether a column in a list exists or not by passing in the column name as a string value.

It is a helpful method when working with SharePoint field existence.

  1. public bool determineIfColumnExists(ref string nonExistingColumnName, params string[] columnNames)
  2. {
  3. nonExistingColumnName = string.Empty;
  4. bool flagExists = false;
  5. if (this.List != null)
  6. {
  7. foreach (string columnText in columnNames)
  8. {
  9. if (columnText != string.Empty)
  10. {
  11. try
  12. {
  13. SPField columnField = this.List.Fields.GetFieldByInternalName(columnText);
  14. flagExists = columnField != null;
  15. }
  16. catch
  17. {
  18. flagExists = false;
  19. }
  20. if (!flagExists)
  21. {
  22. nonExistingColumnName = columnText;
  23. return flagExists;
  24. }
  25. }
  26. }
  27. }
  28. return flagExists;
  29. }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>