2013-06-13

Suppose the Share Point ListField DateTime Field needs to update programmatilcally as default value as Today . Below is the code for the updating Today as the Default Value.

using (SPSite site = new SPSite("http://Sitename/"))
{
  using (SPWeb web = spsiteObj.OpenWeb())
  {
     SPList list = web.Lists["list"];
     Guid id=list.ID;
     SPField dateTime = list.Fields["dateTimeField"];
     dateTime.DefaultValue = "[today]";
     dateTime.Update();
     look.Update();
   }
}

 

About the author 

Anil Lakhagoudar