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

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

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

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :SharePoint


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

View Complete Post

More Related Resource Links

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)

How to add List item in search results for anonymous in a publishing site?

Hi all,   For now, results in Library (document set or not) are shown and the link is the binary file. This is ok. But for list, anonymous users can't view results. As logged in I see the items in the AllItems.aspx page. How could I allow this result to be viewed by anonymous users too?      Thank you,   Benoit Pironet

MOSS Search Not Returning Results from A List

Hello All,   Problem: The MOSS Search is not returning results from a subsite (and list within it). It however returns results for most of the other sites in the web application. Environment: 2 Application Servers. One of these is the index and query server. The same server is also the search server for the content databases. 5 web front end servers. Other Notes: The MOSS installation has several web applications. We however have one site within it that is not returning the required results. The results that we are looking for are located in a particular list. When one searches against the items in the list, some appear and others do not. We also get results from RSS feeds that track changes to the list in the last week. Also, some of the results returned are links to the new item in the list (that is, when you click on new to create a new item). There are no search errors in the application log. The web application was recently upgraded from WSS 3.0 on a single server to MOSS 2007 in a server farm. There are no sql index errors. The WSS Search and Office Search Services are working and have been restarted. The credentials have also been re-entered. We get less than 20 errors in the crawl logs (out of close to 800k docs). I have checked the rights for the default content access account, and it has dbo rights to the content db and search db. It also has read (and now admin

List view search and results - No Column view?



Recently we have moved from Portal server 2003 to Sharepoint Server 2010 and can't seem to find how to search a particular list vie(filtered view) and also how to have the search results return in column view.
Previously in Portal server 2003, our end users had the ability to do full text search in any list view. This allowed our end users to easily search a subset of a list. The returned results were also in a column view

In Sharepoint Server 2010, the list view search, searches all items in the lists(instead of the filtered list view) and also does NOT return the results in column view.

Is there anyway around this?

Michael M

Data List Returning Incomplete Results


Hi All

I have a page where users can search by company name, the data list is pulled from an Excel spreadsheet hosted on the site.  I'm seeing some strange results returned, for example:

In the company field say there are the following entries:

Anns Company
Bernards Business
Company B
Dermots Domain
Property Company

If I search for "Com" I get the following returns (correct):

Anns Company
Company B
Property Company

If I search for "Der" I get my "Sorry there are no matching results" message (Incorrect)

If I search for "Ann" I get the following returns (Correct):

Anns Company

And if I search for "e" I get the following returns (Correct):

Bernards Business
Dermots Domain
Property Company

It seems random as to why it doesn't return some values, I've tried moving rows around to see if that's the problem but it makes no difference.  My range is set correctly in the spreadsheet.

When I debug the VB code behind, when I search for something that works correctly e.g. "Com" in the above example, once enter the value and click search Visual Studio begins steping into

Make Search Results Look Like a SharePoint List

How could I transform XSLT in the search result page of SharePoint to make it look similar to a list view?  i.e. show metadata columns for the search results page.  I would like to do this for specific "This List:" type search results pages.

Cannot able to Modifying SharePoint KPI List views

i created a new kpi list in which i am trying to modify the view . but the chnages which i doen is not reflecting

Clicking on "new" in a KPI list results in an error page "File Not Found".


KPI lists on other sites within sharepoint work fine, but any KPI list on this particular site will result with a file not found page when you try to create a new KPI. It happens with any of the 4 "new" choices (sharepoint list, excel workbook, sql, or manually entered data).


Any thoughts on what is causing this or how to fix it?


Site Analytics - how get specific list item id to display in Top Page Results

We have created a new Site to store Knowledgebase Articles. The articles are being added as items in the list. We now want to find which are the most viewed items. When I look at Site Analytics, I find several pages being returned including what I believe are the Items viewed. When I look at the details under the graph or when exported to Excel, this the is extent of the Page URL (/lists/kbarticles/dispform.aspx?...). There are several occurances of this same URl which I expect are separate items that have been viewed. How do I get the ID of the item or other information, so I can track it to the specific Knowledgebase Article? Additional information: I can click on the URl and it will take me to the unique Knowledgebase Article. 

Ready made List Types provided by SharePoint

SharePoint provides some out of the box List Types. Some of the most used ready made list types that SharePoint provides currently are listed below:

Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.

Dropdown list in ASP.NET - How to get value selected

am sure this must be very simple, but unforunately I can't figure it out.
I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list.
I would really appreciate your help

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

Compare List


i have got two list<string> containing datas

i would like to compare the both list and the result to new list whch does not contains the same data.(basically unique data)

eg shown below..

list A       list b          list c

a             a                 d

b           d                    c

c            f                   e

f            e

plz let me knw..

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