Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm quite nice to Sharepoint so pardon my lack of knowledge.

In my web part design, I am using this to obtain date and time from the user:

<SharePoint:DateTimeControl ID="interviewSlot" runat="server" />

So I am trying to add the DateTime object from interviewSlot into a particular Item in my "Application" list here:

objJobApplicants = objCurrentWeb.Lists["Application"];
foreach (SPListItem objApplicantItem in objJobApplicants.Items)
{
     if (objApplicantItem["ApplicantName"].ToString().Equals(applicant))
     {
         objApplicantItem["InterviewTimeslot"] = interviewSlot.SelectedDate;
     }
}

InterviewTimeslot is a of a Date and Time data type in the list.

The code seems to run fine, however the selected date in the web part is not being added to the Application list. Am I missing some step that is needed specifically for a DateTime object?

Thanks!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

From what you posted, looks like you need to call Update() on the item:

if (objApplicantItem["ApplicantName"].ToString().Equals(applicant))
{
    objApplicantItem["InterviewTimeslot"] = interviewSlot.SelectedDate;
    objApplicantItem.Update();
}

SPListItem.Update method

share|improve this answer
    
THanks this seemed to have worked for me! –  lyk Apr 5 '13 at 6:55
    
If you are new to SharePoint, you should make yourself familiar with the Update() method. Many, many objects in the SharePoint object model have this method, and what it does is write the changes you make to an object into the database so that the changes persist. –  Dylan Cristy Apr 5 '13 at 14:08
    
Noted, thank you very much! :) –  lyk Apr 9 '13 at 4:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.