SharePoint

How to update Field’s value of an Existing SP List

 

SPSecurity.RunWithElevatedPrivileges(delegate() {
using (SPSite oSPsite = new SPSite(Your SP Site Collection URL))
{
foreach (SPWeb oSPWeb in oSPsite.AllWebs)
{
SPList lst = null;
oSPWeb.AllowUnsafeUpdates = true;
try
{
lst = oSPWeb.Lists[Your List Name];
}
catch (Exception ex)
{
continue;
}
try
{
oSPField = lst.Fields.GetField("FileType");
}
catch
{
blnColumnFileTypeExist = false;
}
if (blnColumnFileTypeExist)
{
SPListItemCollection items = lst.Items;
foreach (SPListItem item in items)
{
item["FileType"] = "HMZ4";
item.Update();
}
}
}
}
});

Standard

Leave a Reply

Your email address will not be published. Required fields are marked *