Question

Here BranchAdmin is person or group column and from the below code i want to remove the value BranchAdmin column when the username equals to branch admin name.

try
                         {
                             foreach (SPListItem item in branchList.Items)
                             {
                                 string strBranchAdmin = Convert.ToString(item["BranchAdmin"]);
                                 if (strBranchAdmin == Username)
                                 {
                                     item["BranchAdmin"] = string.Empty;
                                 }

                             }
                             branchList.Update();
                         }
                         catch (Exception ex)
                         {

                         }
Was it helpful?

Solution

SPFieldUserValue noUser = null;
item["BranchAdmin"] = noUser;
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top