Create a Sharepoint Blog comment in code ...

Posted by Ren Hoek on Stack Overflow See other posts from Stack Overflow or by Ren Hoek
Published on 2010-03-19T17:13:46Z Indexed on 2010/03/19 18:11 UTC
Read the original article Hit count: 327

Filed under:
|

I have the need to create Sharepoint blog comments by code:

                       SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                    sw.AllowUnsafeUpdates = true;

                    SPList spList = SPContext.Current.Web.Lists["Kommentare"];
                    SPListItem listItem = spList.Items.Add();
                    listItem[listItem.Fields["Titel des Beitrags"].InternalName] = SPContext.Current.Item["Title"];
                    listItem[listItem.Fields["Titel"].InternalName] = titlearea.Value;
                    listItem[listItem.Fields["Textkörper"].InternalName] = CommentArea.Value;
                    listItem[SPBuiltInFieldId.Author] = curUser;
                  //  listItem[SPBuiltInFieldId.Modified] = curUser;
                    listItem.Update();
                    //spList.Update();
                    sw.AllowUnsafeUpdates = false;
                    });

but I allways get a "Invalid data has been used to update the list item. The field you are trying to update may be read only"

I tried Systemupdate and the values seem to be valid.

Has Anybody an idea?

Greetings ren

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about c#