Short solution for short problems

Randomly shuffle an IList

Here some code to shuffle an IList randomly:

/// <summary>

/// Function to randomly shuffle an IList

/// </summary>

/// <param name="list">The IList to shuffle</param>

public static void ShuffleList(IList list)


    Random rnd = new Random();


    for (int i = list.Count - 1; i > 1; --i)


        int n = rnd.Next(i - 1);

        object t = list[i];

        list[i] = list[n];

        list[n] = t;




How to hide WSS list item properties

I was working on a SharePoint project, where I need to test and set an item field, but this field should not be visible to users.

After looking in SharePoint configuration, I realized it could not be done this way. So the solution I found was to edit the tp_fields in the 'alllist' table of the content database. First you have to look for the tp_id of the list where you want to hide the property. Then you copy the contents of the tp_fields field and paste it in a sql command like this:

update alllists 
set tp_fields = '

<Field Name="_Status" Hidden="TRUE" FromBaseType="FALSE" Type="MultiChoice" 
DisplayName="Status" Required="FALSE" FillInChoice="FALSE" ID="{1dab9b48-2d1a-47b3-878c-8e84f0d211ba}" 
Version="7" StaticName="_Status" SourceID=http://schemas.microsoft.com/sharepoint/v3/fields 
ColName="ntext2" RowOrdinal="0">
    <CHOICE>Reviewed by Author</CHOICE>
    <CHOICE>Reviewed by Reviewer</CHOICE>
    <CHOICE>Reviewed by Safety</CHOICE>
    <CHOICE>Reviewed by QS</CHOICE>
    <CHOICE>Released by Reviewer</CHOICE>
    <CHOICE>Released by Sefaty</CHOICE>
    <CHOICE>Approved by Management</CHOICE>

</Field><Field Name="Author"/>'
where tp_id = '8257d5d1-789d-37cd-b4sc-bf61f4761451'

The ... replace the other fields in the list. So when you set hidden="true" the field is still accesible trough code, but not in SharePoint gui, or even SPD. If you have made a view that consited this field, it will keep showing the field. But in a new view, the field will not be available anymore. So if you still want it to appear in a view, then create the view before you hide the field or just unhide it for a moment to create a view and hide it again afterwards.