Sep 19, 2009

Programmatically adding an item in the list

In the previous post i have explained how to create a list programmatically, here i am adding an item in the list.

Sample code:

SPListItemCollection oListItemColl = SPContext.Current.Web.Lists[“”].Items;

oWeb.AllowUnsafeUpdates = true;

SPListItem oItem = oListItemColl.Add();

oItem["Column1"] ="Test Value ";

oItem["Column1"] = "Test Value 2";

oItem.Update();

oWeb.AllowUnsafeUpdates = false;

Enjoy !!!

No comments:

Post a Comment