SharePoint’s type of List & its Item’s Field

Calendar List

Field Name Type
Location String
Start Time DateTime
End Time DateTime
Description String
Title String
Category String
fAllDayEvent Boolean
   
   

Contact List

Field Name Type
Title String
FirstName String
FullName String
Email String
Company String
JobTitle String
WorkPhone String
HomePhone String
CellPhone String
WorkFax String
WorkAddress String
WorkCity String
WorkState String
WorkZip String
WorkCountry String
WebPage String
Comments String

Announcement List

Field Name Type
Title String
Body String
Expires DateTime

Disscussion List

Field Name Type
Title String
Body String

Task List

Field Name Type
Title String
Status String
PercentComplete String
Priority String
Body String
StartDate DateTime
DueDate DateTime
AssignedTo user

Issue List

Field Name Type
Title String
Status String
Comments String
Priority String
Description String
DueDate DateTime

Link List

Field Name Type
URL SPFieldUrlValue
Notes String

Programmatically add an item/Contact to a SharePoint 2010 Contact List

Here,in this post I am going to describes how we can programmatically add an contact to the SharePoint 2010.

We go here step by steps.So.let’s begin.

(1) Creating the Contact List.

//Get  the Site under which you want to create Contacts.

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 Contacts.
SPList list = web.Lists["Contacts"];

Now,Up to this we has the instance of Contact list.

(2)Adding Contact In to Contact list.

To Add/Create the Contacts we need to update following field.

Field Name Type
Title String
FirstName String
FullName String
Email String
Company String
JobTitle String
WorkPhone String
HomePhone String
CellPhone String
WorkFax String
WorkAddress String
WorkCity String
WorkState String
WorkZip String
WorkCountry String
WebPage String
Comments String

//Adding event into list
  SPListItem contact = list.Items.Add();

contact["Title"] = “Rajput”;

contact["FirstName"] = “Chirag”;

contact["FullName"] = “Rajput Chirag”;

contact["Email"] =  “Chirag@test.com”;

contact["Company"] = “My Company”;

contact["JobTitle"] = “Software Eng.;

contact["WorkPhone"] = “0303- 1233344” ;

contact["HomePhone"] = “2121-323232”;

contact["CellPhone"] = “+1213232323”;

contact["WorkFax"] = “122132-3232”

contact["WorkAddress"] = “ddadadada”;

contact["WorkCity"] = “Bangalore”;

contact["WorkState"] = “Karnataka”;

contact["WorkZip"] = “1212-32”;

contact["WorkCountry"] = workcountry" ;

contact["WebPage"] = “http://Mylog.com”;

contact["Comments"] = “MyComments”;

contact.Update();

Your,final code will look like this.

//Get  the Site under which you want to create Contacts.

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 Contacts.
SPList list = web.Lists["Contacts"];

//Adding Contact into list
  SPListItem contact = list.Items.Add();

contact["Title"] = “Rajput”;

contact["FirstName"] = “Chirag”;

contact["FullName"] = “Rajput Chirag”;

contact["Email"] =  “Chirag@test.com”;

contact["Company"] = “My Company”;

contact["JobTitle"] = “Software Eng.;

contact["WorkPhone"] = “0303- 1233344” ;

contact["HomePhone"] = “2121-323232”;

contact["CellPhone"] = “+1213232323”;

contact["WorkFax"] = “122132-3232”

contact["WorkAddress"] = “ddadadada”;

contact["WorkCity"] = “Bangalore”;

contact["WorkState"] = “Karnataka”;

contact["WorkZip"] = “1212-32”;

contact["WorkCountry"] = workcountry" ;

contact["WebPage"] = “http://Mylog.com”;

contact["Comments"] = “MyComments”;

contact.Update();

Thanks.

Programmatically add an item/event to a SharePoint 2010 calendar

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.