Monday, 30 July 2012

"Missing site templates in SharePoint 2010"


If you have activated SharePoint Server Publishing Infrastructure feature on the site collection level, when you try to create a new sub-site on SharePoint 2010, there are only two site templates available by default: Publishing Site with Workflow and Enterprise Wiki.  Where are the other site templates?
In SharePoint 2010, you have to ‘enable’ the other site templates first.  To do so, go to Site Settings –> ‘Page layouts and site templates’ under ‘Look and Feel’ section.  On the ‘Page Layout and Site Template Settings’ page, you can specify which site templates will be available for creating subsites in this site collection (e.g. Blog, Records Center)


Sunday, 29 July 2012

List Throttling in SharePoint 2010

List Throttling is the new concepts introduced in SharePoint 2010 to set the limits on the rows of data can be retrieved from a SharePoint list or document library at one time. Suppose a SharePoint lists contains two thousand records and someone trying to retrieve all items, then List throttling will not allow to do so.
Throttling setting will be apply for both views created by the user also for queries executed in custom code also. When executing queries, the number of results returned will be determined by the throttle settings for the given list and the rights of the current user.

You have to set the Throttling settings in the Central Administration.

The default value for this setting is 5,000, which means that results returned from an SPQuery or SPSiteDataQuery object will be generally limited to 5,000 items for both super users and normal users.

In order to retrieve information using the object model in order to retrieve up to the number of items specified in the List query size threshold for auditors and administrators property, there is a property you need to set in your query object.  The property is called QueryThrottleMode and it applies to the SPQuery and SPSiteDataQuery classes.  You simply set this property to Override and then use your class instance to query.  Here’s a simplified example:
using
 (SPSite theSite = new SPSite("http://foo"))
{
using
 (SPWeb theWeb = theSite.RootWeb)
{
SPList
 theList = theWeb.Lists["My List Name"];

SPQuery
 qry = new SPQuery();
qry.QueryThrottleMode = SPQueryThrottleOption.Override;

//set the Query property as needed to retrieve your data

            SPListItemCollection coll = theList.GetItems(qry);

            //do something with the data
}
}


"Missing Out-of-box List and Library templates in SharePoint 2010"

Missing Out-of-box List and Library templates which are given below:
 Announcements, Issue tracking, Links,Calendar,Discussion boards and some other list templates that i was looking for.

Anyways, to bring the missing templates back all i did was, activated some site and site collection features which were not activated by default and which were responsible to add these list\library templates to the create page.

Here is the list of Features to activate -

Site collection feature -

  • SharePoint Server Standard Site Collection features.

Site Feature for Activate:


  • Team Collaboration Lists (Provides team collaboration capabilities for a site by making standard lists, such as document libraries and issues, available.) 
  • SharePoint Server Standard Site features (Features such as user profiles and search, included in the SharePoint Server Standard License.) 


Thursday, 26 July 2012

Use the 'GetDataTable' method to display items from a list into a GridView control.


SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["Emloyess Data"];
SPListItemCollection items = list.Items;
GridView1.DataSource = items.GetDataTable();
GridView1.DataBind();

Using CAML Query to Get Data from SharePoint List


 SPWeb oWebsite = SPContext.Current.Web;


            SPList objList = oWebsite.Lists["Emloyess Data"];
           const string camelQry= @"<Query><Where><And><Eq><FieldRef Name='Title' /><Value Type='Text'>Sharepoint Developer</Value></Eq><Eq><FieldRef Name='Name' /><Value Type='Text'>Amjad Ali Khawaja</Value></Eq></And></Where></Query>";
           SPQuery sp = new SPQuery();
           sp.Query = camelQry;
           SPListItemCollection splc = objList.GetItems(sp);

           foreach (SPListItem li in splc)
           {
               Label1.Text += li["Title"] + " " + li["Name"] + " " + li["ID"]  ;
           }
}