업데이트하려는 필드는 프로그래밍 방식으로 목록에 목록을 추가하는 동안 읽기 전용 오류 일 수 있습니다.

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

문제

웹 파트 페이지에서 리디렉션 된 응용 프로그램 페이지에서 목록 항목을 추가하고 있습니다.

내 코드는 다음과 같습니다.

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"));

    }
.

여기 필드 PictureCart 목록에서 유형을 조회합니다.GeneraCodicicetagcode는 사람이나 그룹의 유형입니다.응용 프로그램 페이지로 리디렉션하는 Java 스크립트는 다음과 같습니다.

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

페이지가 응용 프로그램 페이지로 리디렉션되면 위에서 언급 한 오류가 발생합니다.

누락 된 것입니까?제발 도와주세요.

도움이 되었습니까?

해결책

오류의 정확한 이유를 찾을 수 없습니다. 그러나 Pls는 다음 사항을 거칩니다 :

1) ReadOnly 필드를 업데이트하는 방법.

먼저 false로 false로 설정하고 필드를 업데이트 한 다음 다음과 같이 되돌리십시오.

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

2) lookupfield 업데이트 :

new SPFieldLookupValue(1, "ASP.Net");
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top