API for interacting with SharePoint from .NET code deployed to the server.
0
votes
1answer
2k views
GridView control - paging with linq. Where is objectDataSource?
I have visual web part with custom logic which retrieves me strongly typed list (not SPList -> .NET list object) which than I bind to gridview which has paging enabled. That works fine. Problem is: ...
1
vote
2answers
862 views
Server timeout issue when getting 500000 records from SharePoint 2010 list
I am working on Sharepoint 2010. I want to get 500000 list items from the "Announcement" list. I got server timeout issue and the code is given below
SPList list = web.Lists["Announcements"];
SPQuery ...
10
votes
3answers
3k views
How to automate entry of external column data in BCS?
I have a document library, Resumes, that has a large number of resumes in it. There is a regular column on that library, called EmployeeID, that is already populated. I have an external content type ...
2
votes
2answers
1k views
Iterate through discussion list
I have SharePoint 2007 discussion list. I want to iterate over all items in the list, so I do the following:
var list = web.Lists["discussion"];
var listItems = list.Items;
foreach (var listItem in ...
1
vote
2answers
65 views
How memory intensive is a list of SPItems?
I want to create a list which can store SPItems for "offline" reference.
I would hope no more than 3000-6000 items.
Do you think this is pushing it memory wise?
Thanks in advance
2
votes
3answers
127 views
4 using statements looks messy? Any suggestions on what is a better way to code this?
Imagine the following code:
using (SPSite spSite = new SPSite(this.SiteURL))
{
using (SPWeb spWeb = spSite.OpenWeb())
{
using (SPSite spSite2 = new SPSite(this.SiteURL2))
{
...
2
votes
3answers
12k views
Sharepoint 2010 how to get all items in a folder contained in a list?
I have a list that contains folders.
Using c# and object model, how can I see if the folder contains any items, or return a collection of all the items in that folder.
2
votes
1answer
771 views
How do I remove all users from an SPGroup object?
I have an SPGroup object populated, how can I remove all members from the group, so that essentially I start with a fresh group.
I can't delete and recreate it, so I need a way to work with the ...
1
vote
1answer
1k views
SharePoint 2010 - Change order of User Profile properties
I would like to know how to change the display order of the out of the box user profile properties using sharepoint object model ?
I would like to move OOTB properties into my custom section.
4
votes
2answers
360 views
Performance of search vs. using the object model?
Does anyone know how the performance of searching for items compares to using the object model to access them?
When I say "object model" i mean using SPList to get a collection of SPListItems and ...
1
vote
1answer
356 views
Why are SP objects (such as SPUser) not serializable?
I tried to create some private variables that were SPUser's, but I was given an error to the tune of 'SPUser is not marked as Serializable'.
Why?
I know these objects contain a lot of contextual ...
0
votes
1answer
102 views
Proper way to retrieve list data asynchronously?
I have done this in the past using jQuery's ajax function and the SharePoint web services, but I'm curious if it is considered a better practice to use the Javascript Object Model?
Also, is it secure ...
2
votes
1answer
611 views
Creating Managed Metadata Field from XML definition
I have successfully recreated all other Column types in SharePoint using the SPFieldCollection.AddFieldAsXml(string xml) method. However, the same method fails for the TaxonomyFieldTypeMulti field ...
23
votes
2answers
3k views
When to use OpenWeb() vs RootWeb
I am a little confused on the pro's and con's of each. When is it good to use OpenWeb() vs RootWeb, especially in the context of a using statement.
4
votes
3answers
937 views
How can I modify a file stored in SharePoint via PowerShell?
I have some files in SP 2010 that are simply HTML, and I need to modify the contents of those files in a systematic manner.
Is there a good way to do this using powershell? Imagine that I want to ...
1
vote
2answers
2k views
Scope in your query does not exist
I'm developing a web part (in VS 2010 for SharePoint 2010) to seach all content in a Publishing Site Collection. I have the following code (just testing before I change the scope and the select ...
0
votes
1answer
1k views
how can i get Web Analytics database name with Object Model?
First let me say, that all of we doing in sharepoint is base on the object model, so i can go to Central Administration and get my "Web Analytics Service Application" Database Name and Server Name, ...
1
vote
2answers
315 views
Updating an SPListItem without knowing SPSite or SPWeb
I'm building a custom web part that is running an SPSiteDataQuery. I will be running this query across all site collections, and displaying the results, together, in 1 web part. Users interacting with ...
5
votes
1answer
363 views
Custom Web Service not cannot find User
I have created a Custom Web Service for my .NET application that performs various functions against a Sharepoint 2010 site. I use a standard function to run each function as an impersonated user (so ...
0
votes
2answers
491 views
Add site column to site content type error
var objWeb = properties.Feature.Parent as SPWeb;
Guid webPublishingGuid = new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb");
SPFeature feature = null;
SPSite site = objWeb.Site;
feature = ...
3
votes
1answer
2k views
How do I query a list using CAML and SPQuery?
I have a SPList but I don't need to go through everything in that list. I need to establish a CAML query so I can limit the list items. Then, go thru each item from the query result and do something. ...
1
vote
2answers
271 views
Powershell calling custom code has SPWeb.CurrentUser = null (in certain cases)
I have a custom assembly which contains code to setup Variations for a SharePoint 2010 Publishing site. This code is based off a blog post from Waldek
I have a PowerShell script in which I create a ...
4
votes
1answer
1k views
How to find the Author Name using SP Client Context in SharePoint 2010?
I am trying to find the Author Name(created by) for a given Item Id using the SP Client context in SharePoint 2010.
Below the code snippet
var ctx = new SP.ClientContext.get_current();
...
6
votes
2answers
173 views
Choosing between API and web services
We are designing a system where we will have a service facade, behind this facade will be functionality to update SharePoint. For example to move an item from one list to another.
What we are ...
2
votes
4answers
270 views
Document Library throws NullReferceException everytime I try to grab an item
This code is from a sequential workflow. I am trying to grab the most recent item in a document library. I check to make sure there are more than zero items in the library, then I try to grab the most ...
3
votes
3answers
4k views
Sharepoint 2010: Custom “New Item” form - showing ribbon and binding events to ribbon buttons
We've created a custom New Item page for our list on our site in Sharepoint 2010 with this code:
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table ...
1
vote
2answers
2k views
Why httpcontext.current is null in sharepoint 2010 while Implementing the Custom Membership Provider?
SharePoint 2007 we can able to use the Httpcontext.current object But in SharePoint 2010 we are unable to get the httpcontext.current object. It will return the values.
How can i get the or Create ...
2
votes
4answers
5k views
Make a copy of sharepoint site under a new name
Since we can't save SharePoint site (with publishing feature enabled) as Template, I'm looking for a way to do this programmatically :
Make a copy of "SiteA" with a new name
"SiteB" under the ...
4
votes
3answers
1k views
Should I dispose SPWeb or SPList?
I am doing a whole bunch of things with one SPWeb and many SPLists. If I just dispose web in the finally section would that dispose all of SPLists that I instantiated? (btw, I understand the concept ...
3
votes
1answer
351 views
Possible to get all SiteCollections in a WebApplication from SPContext.Current?
I would like to look at all Site Collections that are in the current web application based on SPContext.Current. Is there a way to do this? If not, how can I achieve this?
5
votes
1answer
2k views
Fastest way for looping through a SPWebCollection
I've developed a console application for looping through all the webs inside my SharePoint 2010 site, but it's kind of slow, until the point that it throws OutOfMemory exception. This is the code I ...
2
votes
1answer
242 views
Why do I sometimes have to use different SPQuery tags?
Every SPQuery's query should have
<View><Query> query... </Query></View>
tags?
Sometimes I have to put without those tags to get it work and some times I have to put it ...
7
votes
3answers
2k views
Is there a way to see if an SPField was created by a user?
I have some code where I am going through all of the Fields that belong to a content type. I'm curious if there is a way to check to see if the SPField was created by a user or if it is a system ...
0
votes
1answer
225 views
RefinementWebPart - UseDefaultConfiguration property
I'm trying to create a filter dynamically through code, and for that I need to set the property UseDefaultConfiguration to false.
However, just this simple thing below causes the webpart to "hang" on ...
1
vote
1answer
911 views
Getting SPList object by Guid giving exception “List…does not exist at site with URL”
I am trying to load a drop down list with the same items that a lookup field uses. I thought it would be relatively straightforward, but the line
SPList lookupList = ...
2
votes
1answer
246 views
Setting the value of a custom web part property using object model
Let's say I have a reference to a web part that I got by using a SPLimitiedWebPartManager. How can I set the custom properties of that web part? For example, if it is a stock ticker web part, how do I ...
2
votes
2answers
155 views
Sharepoint Web Part restrict to zone
Is there any way to restrict a web part to a certain zone? I know I can restrict it by using the AllowZoneChange flag, but is it possible to make sure the web part can only be added to certain zones? ...
0
votes
1answer
152 views
SharePoint Web Part Gallery details of each web part
When using SPWeb.GetCatalog(SPListTemplateType.WebPartCatalog), it returns an SPList which of course contains a SPListItemCollection of the web parts in the web part gallery.
When looping through the ...
1
vote
1answer
179 views
SPWeb.Webs, foreach and var
See below:
SPWeb currentWeb = SPContext.Current.Web;
foreach (var web in currentWeb.Webs)
{
// web is object here - why?
}
SPWebCollection implements IEnumerable<SPWeb> (among other ...
0
votes
1answer
571 views
Programmatically enumerating Web Part Zones of a Publishing Page Layout
I have a situation where a class I have is passed a PublishingPage instance and I want to enumerate any and all web part zones that are used in the Layout Page for this page.
This is proving tough.
...
0
votes
2answers
304 views
Sharepoint 2007 Current User ObjectModel
I'm trying to use the object model of Sharepoint 2007 to make some changes over a list and read users and groups web settings...
For that I developed a Web Service (WCF) that is stored in the same ...
0
votes
1answer
433 views
Re-order Content Types for a List in code
Has anyone been able to re-order content types for a list in code?
If I'm given a specific content type, I want to make it the default in a list, by re-ordering the SPList.ContentTypes collection and ...
3
votes
1answer
525 views
SPLongOperation never ends
I have an SPLongOperation that occasionally fails to redirect the user to a new page when the operation completes. I'm not sure what circumstances cause the problem, since I don't yet have a reliable ...
0
votes
1answer
847 views
Add an item with lookup field using object model SP2010?
Can someone please post sample code which shows how to deal with a lookup column during an item insert (using object model).
Here is the basic framework for an insert:
SPListItem oListItem = ...
2
votes
2answers
976 views
Set custom publishing page layout custom field programatically
I have a custom publishing page content type, based on the Publishing Article Page content type. On this content type, I have a custom field named "PageContentCategory". In my code to create new ...
1
vote
1answer
541 views
Custom ECB dropdown menu API?
In 2010 (or 2007) is there a server control that is responsible for rendering of ECB menus? For example, if I wanted to create a custom UI for a Document Library (NOT using XSL/DataViewWebPart/etc), ...
0
votes
3answers
356 views
How to find newly added item in the sharepoint portal?
How to find the recently added item in the share point page
If the any user added the items in the custom list, library, list,Announcement, Picture library,etc.........
i need to show all item that ...
0
votes
1answer
196 views
SPListItem IsNew Functionality?
In OOB SharePoint, many of the lists render a "New" graphic when an item is "New". I found this posting which indicates how to determine this from an XSL file: ...
0
votes
1answer
1k views
Event SPListItem Recurrence Text?
Is there a way to get the text displayed for the "Recurrence" field on the View Item screen for an OOB "Event" list item through the object model? For example, I see:
"Every 1 month(s) on the first ...
0
votes
3answers
808 views
SPList.GetItems(query) does not return SPListItems where the permissions are not inherited
I'm using the following code:
protected void TraverseFolder(SPList list, SPFolder folder)
{
SPQuery qry = new SPQuery() { Folder = folder };
SPListItemCollection listFolderItems = ...
