kamagra how much to take

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:

public static bool ViewFieldComparison(SPView firstView, SPView secondView)
{
if (!Equals(firstView.ViewFields.Count, secondView.ViewFields.Count))
{
return false;
}
string[] firstViewArray = new string[firstView.ViewFields.Count];
string[] secondViewArray = new string[secondView.ViewFields.Count];
firstView.ViewFields.ToStringCollection().CopyTo(firstViewArray, 0);
secondView.ViewFields.ToStringCollection().CopyTo(secondViewArray, 0);
for (int i = 0; i < firstViewArray.Length; i++) { if (!Equals(firstViewArray[i].CompareTo(secondViewArray[i]), 0)) { return false; } } return true; } [/csharp] 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: [csharp] public static bool DoesViewExist(string view, SPList list) { foreach (SPView view in list.Views) { if (Equals(view.Title, view)) { return true; } } return false; } [/csharp]

Share

3 Comments

  1. vairamuthu says:

    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)

  2. vairamuthu says:

    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)

  3. komal says:

    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.

Trackbacks/Pingbacks

  1. Links (5/29/2008) « Steve Pietrek - Everything SharePoint - [...] SPView Field Comparison [...]

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>