Monday, January 16, 2012

Programmatically make the SharePoint choice field default value to null

using (SPSite site = newSPSite("http://serverName:1111/sites/sample"))
{
using (SPWeb web = site.RootWeb)
{
SPList list = web.Lists.TryGetList("BugsList"); foreach (SPField field in list.Fields)
{
if (field.Title == "Choice")
{
field.DefaultValue =
null;
field.Update();
}
}
list.Update();
}
}

No comments:

Post a Comment