About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



SPView Field Comparison

When programmatically working with data that is collected in SharePoint lists, you are undoubtedly going to employ SharePoint views, denoted by SPView objects. When working with multiple views, there may come a time when it is necessary to do rudimentary field comparison between two views.

In order to do this, you can use this simple method below:

C#:
  1. public static bool ViewFieldComparison(SPView firstView, SPView secondView)
  2. {
  3. if (!Equals(firstView.ViewFields.Count, secondView.ViewFields.Count))
  4. {
  5. return false;
  6. }
  7. string[] firstViewArray = new string[firstView.ViewFields.Count];
  8. string[] secondViewArray = new string[secondView.ViewFields.Count];
  9. firstView.ViewFields.ToStringCollection().CopyTo(firstViewArray, 0);
  10. secondView.ViewFields.ToStringCollection().CopyTo(secondViewArray, 0);
  11. for (int i = 0; i <firstViewArray.Length; i++)
  12. {
  13. if (!Equals(firstViewArray[i].CompareTo(secondViewArray[i]), 0))
  14. {
  15. return false;
  16. }
  17. }
  18. return true;
  19. }

If you wanted to firstly test whether the view exists, you can implement this as well based on what types of guards you wanted to realize:

C#:
  1. public static bool DoesViewExist(string view, SPList list)
  2. {
  3. foreach (SPView view in list.Views)
  4. {
  5. if (Equals(view.Title, view))
  6. {
  7. return true;
  8. }
  9. }
  10. return false;
  11. }

  • Share/Bookmark

4 Comments »

  1. [...] SPView Field Comparison [...]

    Pingback by Links (5/29/2008) « Steve Pietrek - Everything SharePoint — May 29, 2008 @ 7:01 pm

  2. Hi

    I need to merge more than on view.

    How can i do that one.Ist view has 3 columns ,second view has 5 columns(3 columns same in view1 + extra 2 columns)

    Comment by vairamuthu — August 1, 2008 @ 8:56 am

  3. Hi

    I need to merge more than on view.

    How can i do that one.Ist view has 3 columns ,second view has 5 columns(3 columns same in view1 + extra 2 columns)

    Comment by vairamuthu — August 1, 2008 @ 8:56 am

  4. Hi,
    This code is really help ful.But i want to find the view field display name.
    if i use ‘viewfields’ property,it is displaying internal name of theview field.For my project i need display name of the view field.
    if you know,kindly give reply.
    Thanks,
    komal.

    Comment by komal — November 26, 2008 @ 7:06 am

RSS feed for comments on this post. TrackBack URL

Leave a comment