Here,in this post I am going to describes how we can programmatically add an Event to the SharePoint 2010.
In SharePoint, Calendar is nothing but the one type of list.So as we are adding item in it,we can create the event for Calendar.
We go here step by steps.So.let’s begin.
(1) Creating the Calendar.
//Get the Site under which you want to create Calendar.
SPSite site = new SPSite(http://localhost);
SPWeb web = site.AllWebs[0];
//Give the Type of List you want to create,in Our case it’s noting but Calendar.
SPList list = web.Lists["Calendar"];
Now,Up to this we has the instance of Calendar list.
(2)Adding Event In to Calendar.
To Add/Create the calendar we need to update following field.
| Field Name | Type |
| Location | String |
| Start Time | DateTime |
| End Time | DateTime |
| Description | String |
| Title | String |
| Category | String |
| fAllDayEvent | Boolean |
//Adding event into list
SPListItem newEvent = list.Items.Add();
newEvent["Location"] = “This is location”;
newEvent["Start Time"] = DateTime.Now;
newEvent["End Time"] = DateTime.Now.AddHours(1);
newEvent["Description"] = “Going for Meting”;
newEvent["Title"] = “New Meting”;
newEvent["fAllDayEvent"] = false;
newEvent["Category"] = “Meting”;
//Create Event in the sharpoint.
newEvent.Update();
Your,final code will look like this.
//Get the Site under which you want to create Calendar.
SPSite site = new SPSite(http://localhost);
SPWeb web = site.AllWebs[0];
//Give the Type of List you want to create,in Our case it’s noting but Calendar.
SPList list = web.Lists["Calendar"];
//Adding event into list
SPListItem newEvent = list.Items.Add();
newEvent["Location"] = “This is location”;
newEvent["Start Time"] = DateTime.Now;
newEvent["End Time"] = DateTime.Now.AddHours(1);
newEvent["Description"] = “Going for Meting”;
newEvent["Title"] = “New Meting”;
newEvent["fAllDayEvent"] = false;
newEvent["Category"] = “Meting”;
//Create Event in the sharpoint.
newEvent.Update();
Enjoy your Calendar Event.
Nice stuff, do keep me posted when you post something similar!
sure,chum.
Pingback: How to write data to existing Sharepoint 2007 Calender List - Programmers Goodies
Its because of stuff like this that I love this site :D You guys rock.
http://legalusdrugstore.com/12.jpg
medication pharmacy math tables http://legalusdrugstore.com/products/antabuse.htm pharmacy technician ce anti acidity
shopko pharmacy stevens point wisconsin http://legalusdrugstore.com/products/vantin.htm aarow pharmacy conn cvs pharmacy annual report
nephrology pharmacy associates http://legalusdrugstore.com/products/zyban.htm pharmacy mexican oxy terramycin
ballard plaza pharmacy seattle http://legalusdrugstore.com/categories/cholesterol.htm kroger hwy 6 pharmacy pharmacy jobs
http://legalusdrugstore.com/products/cipro.htm university of otago school of pharmacy
http://legalusdrugstore.com/18.jpg
jobs for pharmacy technicians in augusta county virginia http://nextdayshippingpharmacy.com/products/rogaine-2-.htm costco pharmacy generic drups diamox
charleston air force base pharmacy http://nextdayshippingpharmacy.com/products/finpecia.htm nas jrb fort worth pharmacy formulary pharmacy residenct in nevada
mid year las vegas pharmacy http://nextdayshippingpharmacy.com/products/entocort.htm nas jrb pharmacy ed discount pack 3
four corners pharmacy delmar ny http://nextdayshippingpharmacy.com/products/glucotrol-xl.htm french pharmacy tennesse pharmacy license
http://nextdayshippingpharmacy.com/categories/general-health.htm university of pharmacy