Il campo che stai tentando di aggiornare può essere letto solo un errore durante l'aggiunta di elemento da elencare a livello programmatico

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/77717

Domanda

Sto aggiungendo una voce Elenco da una pagina dell'applicazione che viene reindirizzata dalla pagina Web Part.

Il mio codice è:

protected void Page_Load(object sender, EventArgs e)
    {
        SPSite site = new SPSite("http://bipc11:1234/sites/webparts");
        SPWeb web = site.RootWeb;
        web.AllowUnsafeUpdates = true;
        SPUser currentUser = web.CurrentUser;
        SPList list = web.Lists["Cart"];
        SPListItem item = list.AddItem();
        item["Picture"] = Request.QueryString["title"];
        Response.Write("<script> alert('Pictrue Updated')</script>");
        item["User"] = currentUser;
        Response.Write("<script> alert('User Updated')</script>");
        item.Update();
        Response.Write("<script> alert('Item Updated')</script>");
        web.Update();
        web.AllowUnsafeUpdates = false;
        Response.Write("<script> alert('Value Added To Cart Successfully')</script>");
        Response.Redirect(Microsoft.SharePoint.Utilities.SPUrlUtility.CombineUrl(web.Url, "/SiteAssets/WebPartPage.aspx"));

    }
.

Qui il campo Picture è di tipo cercare nell'elenco Cart.User è il tipo di persona o gruppo.Script Java per reindirizzare la pagina dell'applicazione è:

function myfunction(title)
     {
        window.location.assign("http://bipc11:1234/sites/webparts/_layouts/AddValueToCartList/AddValueToCartList.aspx?title="+title);
     }
.

Quando la pagina viene reindirizzata nella pagina dell'applicazione, sto ottenendo un errore sopra citato.

Cosa mi manca?Per favore aiuto.

È stato utile?

Soluzione

I am unable to find the exact reason for the error: However pls go through the following points:

1) How to update a Readonly field.

First set Readonly to false and update the field and then revert it back as:

Field.ReadOnlyField = false;
Field.Update();

2) Updating the Lookupfield:

new SPFieldLookupValue(1, "ASP.Net");
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top