Tuesday, September 30, 2008

Programatically updating Field properties

Scenario:
You want to set the Field properties programatically

Code:

using(SPSite siteColl = new SPSite("http://localhost/testsite")){
using(SPWeb web = siteColl.OpenWeb()){

site.AllowUnsafeUpdates = true ;

SPList list = web.Lists["Tasks"];

SPField field = list.Fields["Title"];
field.Description = "This is the title";
field.Update(true);

list.Update();
web.AllowUnsafeUpdates = false ;
}
}
Article:

0 comments: