.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

List Vs Collection

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :.NET Framework
When to go for List and When to Use Collection.

View Complete Post

More Related Resource Links

How to Cache System.Collection.Generic.List object


I need to cache System.Collection.Generic.List object with expiration time

var Root = from feed in feedhotel.Descendants(ota + "HotelContent")
                           where (feed.Attribute("HotelCode") != null)
                           select new xmlhotel()




return Root.ToList();

Is it possible to cache Root.ToList() for some time....

Linq query results to List collection



I have a GridView in my page. I want to use below code in code beind. query nothwing DB using linq . add linq query result to new list and then bind list as gridview Datasource

I use below code . But I don't know how to add results to List? Could any one tell me how !

Public Class OrderCity
        Private _name As String
        Private _city As String
        Public Property name As String
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value

            End Set
        End Property
        Public Property city As String
                Return _city
            End Get
            Set(ByVal value As String)
                _city = value

            End Set
        End Property
    End Class
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim dbe As New SFFAV1DataContext
        Dim latestadsDs = From p In dbe.Products _
                            Select New With {p.Title, p.ProducedCity} _
                             Take (2)

        Dim FilteredList As New List(Of OrderCity)()
        For Each result In latestadsDs
            Dim Menedfcou = Nothing
            FilteredList.Insert(0, Menedfcou)

SOLUTION: Renaming the Title list column globally across the site collection

So, you screwed up like I did, and modified the Title display name of the Item base content type and it has renamed ows_Title across every list in your site collection? Here's how you fix it: //WARNING //If you have come this far, be aware that this tool is a blunt axe. With it, you can cause //all sorts of mayhem and chaos in your site collection. So, to use this, you must be desperate. //or possibly dumb. Apparently, I'm just as dumb as you, because I did it. This is why I wrote //this stupid thing, so stupid people like us can go right on being stupid. //Your choice of weapon in this battle amuses me. Shall we begin? using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint;   namespace RenameField {     class Program     {         static void Main(string[] args)         {             if (args.Length < 3)             {                 Console.WriteLine("Usage: RenameField <url-to-sitecollection> <internal-field-name> <new-fieldtitle>");               &n

CAML query to access List data across multiple site collection.

Hi   Is there any way to get the Task List data across multiple site collection using CAML query. Currently, I have the code which will retrieve the data from a single site collection. Below is the code.                           /***************************************************I am using Moss2007.Thanks!Ravi             SPSiteDataQuery q = new SPSiteDataQuery();             q.ViewFields = "<FieldRef Name=\"Title\" />" "<FieldRef Name=\"Status\" Nullable=\"TRUE\"/>";             q.Lists = "<Lists ServerTemplate=\"107\"/>";             q.Webs = "<Webs Scope=\"SiteCollection\"/>";             q.Query = "<Where>" +                                "<Eq>" +                                     "<FieldRef Name=\"Status\" />" + "<Value Type=\"Choice\">Not  Started</Value>" +                                     "</Eq>" +                         "</Where>";             DataTable dt=null;             using (SPSite s = new SPSite("http://banglabguest1:31000/"))             {                 SPWeb w = s.OpenWeb();                 dt = w.GetSiteData(q);                 w = null;             }                              *************************

c# How to get list of site collection features?

If I have a web application url, how can I get a list of the currently installed site collection features programmatically?

Modifying a list results in "Collection was modified; enumeration operation may not execute"



I am trying to add a list column as well as assign a value to the list column which is newly created in the document libraries available in the site. After the value is assigned, when the second document library is about to iterate, I am getting an error as "Collection was modified; enumeration operation may not execute".

Below is the code i have used:


SPListCollection mylists = currentweb.GetListsOfType(SPBaseType.DocumentLibrary);
 foreach (SPList list in mylists)
 if (!list.Hidden)
AddField("CustomColumn", SPFieldType.Text, list.Fields);
 fieldCol.View.DefaultView = true;
int mouas = 5;
SPFolder folder;
folder.Item["CustomColumn"] = mouas;


How to rectify this?

Thank you

can we use one SharePoint list throughout the site collection?


hi all,

I want to use one list which should be accessible with in the SiteCollection. When I am Creating the List it is available in that purticular site only but i want to use the in all the sites in the siteCollection. So Please tell me how we can use a list in all the sites of the Site Collection?

thanks in advance.................

External Content Type - Read List Operation - "Cannot find a collection element of a supported type.


I'm trying to define External Content Type Operations for an External Content Type. I can add a Connection, Type "WCF Service" no problem. And I can define a "New Read Item Operation" using that connection.

But I can't define a "Read List Operation". I get the following error message, in the Return Parameter Configuration: "Cannot find a collection element of a supported type..." it goes on to say - see the help documentation for supported types. I can't find any help documentation on this.

I've tried returning different types in the provider web service but keep getting the same error. What are the supported types the web service can return?

The reading I've done suggests that you can connect to a non-MS web service using a connection type of "WCF Service". Is this correct? If it is what's the best soap format the web service provider should use - Doc/Literal?



Update all Properties in the User Information List after restoring a site collection to a new domain


hi All

I moved a site collection (content db) from one domain to another. After the site collection was restored i ran the stsadm -o migrateuser -oldlogin -newlogin. The result was that the login id of the user in the source domain was replaced with the login in the destination domain.

However the rest of the properties in the User Information List (paricularly interested in the Email) was not updated.

How can i get all the properties in the User Information List with values in the new domain

Thanks in Advance


Remove List Field Type under site collection


Hi All ,

We have a custom field created and added the same under a webapplication , now I would like to remove this field type from a specific site collection , can anybody suggest as how to go about the same .





Create workflow to create list item in calendar list of a DIFFERENT site collection


I work for a school district.  Each school has a SharePoint calendar.  We set up each school as its own site collection.  I would like to create a workflow that would send their calendar events to a district calendar, which is also its own site collection.

Example,  School A enters creates a new item on their personal school calendar.  They click YES in the column called SendToDistrictCalendar.  The workflow would be triggered to create this same item in the district calendar (which is in a different site collection) when SendToDistrictCalendar is checked YES.

We're using Windows Server 2003 with Windows SharePoint Services 3.0

I am a mid-level SharePoint user.  I would appreciate ANY and ALL help to make this work!!


WSS 3.0 Cross Site-Collection List Lookup


Hi all

New to Sharepoint here, so apologies if the question is unclear.

We would like to store centralised reference data in a dedicated site-collection and allow it to be accessed from other site-collections using list lookups. Can anyone recommend a webpart that would allow us to do this? I've found lots of cross-site list webparts, but not for crossing SC boundaries. Is there an OOTB feature that we could extend to achieve the same thing?




If you have found this post helpful, please click the 'Vote as Helpful' link (the green triangle and number on the top-left).

If this post answers your question, click the 'Mark As Answered' link below. It helps others who experience the same issue in future to find the solution.

Collection Editor for Interfaces (e.g List



I am trying to use the Collection Editor during design time to create a collection. If I use a Collection with class I get the correct colletion editor wizard. In the picture below you can see the empty Collection Editor when I use the list of interfaces

www.ImageBanana.com - Unbenannt.png


public interface ITest
	int Test { get; set;}

public class Test:ITest
	int Test { get; set; }

class MyControl
	// Works in the Collection Editor
	// Don't


If I use the interface the Add Button is gray and I ca

Designer Workflow: update list in another site within collection?

Is it possible with a Designer 2007 created workflow to update an list in another site within the same collection?  I don't see a way to do that and am wondering if I am missing something.
There are no mistakes; every result tells you something of value about what your are trying to accomplish.

Copy list from one site to another site in same collection

What is the easiest way to copy a list from one site to another in the same site collection and still keep the meta data (e.g. created by, modified by)?  Can this be done through SharePoint Designer?

Adding List from another Site Collection


I want to add a list to as a web part on my page in Sharepoint 2007.


The catch is that the list is part of another site collection.

How do I sort this out.


I tried to go to the Data Source Library through Sharepoint Designer and tried adding a new Library.

But the lists from that Site Collection doesn't show.


Is there another way to do this?



SPListItem Update() does not work from list.Items collection.


Hi All,

Not working code:

using System;
using Microsoft.SharePoint;

namespace ConsoleApplication3

class Program
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend