I want to update sharepoint list using foreach loop , i want to update each item on Employee code, how to update each record by employee Code. any help will be appreciated thanks

   context.AuthenticationMode = ClientAuthenticationMode.Default;
                    context.Credentials = new NetworkCredential("Username", "******);
                    Web webObj = context.Web;
                    List listObj = webObj.Lists.GetByTitle("Leave Requests");
                    CamlQuery camlquery = CamlQuery.CreateAllItemsQuery(10);
                    ListItemCollection listitemcoll = listObj.GetItems(camlquery);
                  foreach (DataRow row in dtDataforLeaveDeduction.Rows)
                        string EmployeeCode = row["EmployeeCode"].ToString();
                       foreach (ListItem item in listitemcoll)
                           //int currentyearbalance = Convert.ToInt32(item["CurentYearbalance"]);
                        //currentyearbalance = currentyearbalance + 2;
                        //item["CurentYearbalance"] = currentyearbalance;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.