Posts

Showing posts from August 18, 2013

Caml Query with Lookup field

<Query>   <Where>     <Eq>       <FieldRef Name='Fruit' />       <Value Type='Lookup'>Grapes</Value>     </Eq>   </Where> </Query> <Query>   <Where>     <Eq>       <FieldRef Name='Fruit' LookupId='TRUE' />       <Value Type='Lookup'>15</Value>     </Eq>   </Where> </Query>

SharePoint Custom webpart with SharePoint resource files

Image
Step 1: First we need to create the visual webpart project in visual studio 2010. Step 2: After adding the visual webpart project, in the solution explorer, right click and add new sharepoint mapped folder and refer the folder Resources. Once the resource folder is mapped, right click and add the folder (since so many resource files are present in the 14\Resource folder used by sharepoint and we create our own folder and use it for the particular webpart /particular web application ). Lets call the folder as CustomResource folder. Step 3: Now add the resource file by right click on the CustomResource folder and add new item, select c#, and select the resource file, name it as CustomResource.resx Step 4: Add Empty Element named " App_GlobalResources" Step 5: In Solution Explorer, click on Show All Files icon to view all files. Open SharePointProjectItem.spdata files located under App_GlobalResources node. Add the relavent information to the xml file which includes

How to add ListItem to List, "Person or Group" column

        SPWeb website = SPControl.GetContextWeb(Context);         SPList oList = website.GetList("/Lists/Team%20Members");                 SPListItem item = oList.Items.Add();         SPUser user;         website.AllowUnsafeUpdates = true;          user = website.SiteUsers["MOSSDEV1\\abc"];         item["Member"] = user;         item.Update();         website.AllowUnsafeUpdates = false;