Value does not fall within the expected range. When modifying data type MSFT HELP!!!!

I want to change a column type from multiline text to HTML.

I tried this

            string urlRoot = ConfigurationManager.AppSettings["url"].ToString();
            SPSite site = new SPSite(urlRoot);
            SPList list = site.RootWeb.Lists["Agenda"];
            HtmlField htmlField = new HtmlField(list.Fields, "HTML", "NewHTMLField");
            SPField fieldInContentType = list.ContentTypes["Agenda"].Fields["Body Intro"];
            fieldInContentType = htmlField;
            fieldInContentType.Update();

 

But I got that exception,

 

Any help is appreciated!!!
SimbiosAsked:
Who is Participating?
 
JuanCarnigliaConnect With a Mentor Commented:
This means that you are seeking a "position" on an array, identified by a string (for instance "Body Intro") and that string does not exist on that array.

Please see that Agenda and Body Intro, both exist.

Greetings
0
 
SimbiosAuthor Commented:
both exists! otherwise it would throw another exception in those lines that the first thing I checked!
0
All Courses

From novice to tech pro — start learning today.