views:

31

answers:

1

I'm using WSS3 and C# to create site and I am creating a class to change fields on lists after they have been created. I have already created an SPField.Boolean type with no default value, but after upgrade I need the default value to be set to true. My current code that does not work follows:

           //web is already defined as the current web
           var list = web.Site.RootWeb.Lists["ListWithFieldOnIt"];
           var field = list.Fields.GetField("booleanfield");
           field.DefaultValue = "1";
           field.Update(true);
           list.Update(true);

I have tried to change the default value through the sharepoint instance and sharepoint manager 2007 and neither of those have worked. Does anyone know of any way to set the default value or what I am doing wrong?

Thanks in advance

A: 

Looks like you're doing it correctly according to Programmatically setting the default value of a SPFieldBoolean field. I can't see anything really wrong. My only suggestion would be to try the Update calls without the boolean parameter. From MSDN, SPField.Update Method (Boolean) seems to be meant for site columns rather than columns within a list. Whenever I'm updating a field or list in code, I almost always use the parameterless Update method.

Rich Bennema