Monday, May 28, 2012

Property or indexer 'Microsoft.SharePoint.SPListItem.Title' cannot be assigned to -- it is read only


Property or indexer 'Microsoft.SharePoint.SPListItem.Title' cannot be assigned to -- it is read only :-



 protected void btn1_Click(object sender, EventArgs e)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Announcements"];
                    SPListItem item = list.AddItem();
                    item["Title"] = "New Announcement";
                    item.Update();
                }
            }
        }


No comments:

Post a Comment

Featured Post

Azure OpenAI Chat in C# and Python

Azure OpenAI Chat in C#: // Install the .NET library via NuGet: dotnet add package Azure.AI.OpenAI --version 1.0.0-beta.5   using System; u...

Popular posts