I try to add an item to my sharepoint list from a custom web part. Is there any mistake in my code?
[WebMethod]
public static string AjouterDemande()
{
SPList ListeDemandeConge = SPContext.Current.Site.RootWeb.Lists["DEMANDE CONGÉ"];
SPListItem ListItem = ListeDemandeConge.Items.Add();
ListItem["CODE"] = code;
ListItem["DEMANDEUR"] = Utilisateur.LoginName;
ListItem["DATE DEMANDE"] = DateTime.Today.Date;
ListItem["DATE FIN"] = EndDateD;
ListItem["DATE DEPART"] = StartDateD;
ListItem["DUREE"] = int.Parse(DayCount);
ListItem["PREMIER RESPONSABLE"] = Employe.FirstSuperior.LoginName;
ListItem["DEUXIEME RESPONSABLE"] = Employe.SecondSuperior.LoginName;
ListItem["PRESENCE PRES"] = Boolean.Parse(FirstRespPresent);
ListItem["SOLDE CONGE"] = Conge.SoldeAnneeConge;
ListItem["MOIS"] = int.Parse(StartDateTab[1]);
ListItem["ANNEE"] = int.Parse(StartDateTab[0]);
ListItem["JOURS APPROUVEES"] = 0;
ListItem.Update();
ListeDemandeConge.Update();
return "true";
}
When I use F10 to process debugging step by step and get to my listitem.update()
, it went out without giving any error.