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

Top 5 Contributors of the Month
Gaurav Pal

Home >> Forum >> SharePoint >> Post New QuestionBookmark and Share Subscribe to Forum

Copy complete calendar from one site to another in sharepoint

Posted By: Shruthi BM     Posted Date: February 09, 2011    Points:2   Category :SharePoint
Hi All,

I have request to copy complete calendar from one site to another in sharepoint.

Is it possible to copy calendar from one site to another.

If so, is it possible to link and update automatically any change made in one of the calendars to the other ?


Author: Sunil Yadav       [Moderator]      
Posted Date: February 10, 2011     Points: 5   

Yes you can achieve above functionality by creating a feature which will retrieve a calendar value from site 1 and add it to site 2. Something like shown below.

 // Get referece to Site 1 calender list

SPSite site = new SPSite("http://mysite/site1");
SPWeb mysite1 = site.OpenWeb();
SPListItemCollection listItemSite1 = mysite1.Lists["MyCalender1"].Items;

// Add this to site 2 calender list
SPSite site2 = new SPSite("http://mysite/site2");
SPWeb mysite2 = site2.OpenWeb();
SPListItemCollection listItemSite2 = mysite2.Lists["MyCalender2"].Items;

Also make sure that you do not add duplicate entries

foreach (SPListItem item in listItemSite1)
SPListItem listitem = listItemSite2.Add();
listitem["Title"] = item["Title"];



Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

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