2

新しい編集フォームからタイトルフィールドを非表示にするために次のことを試みていますが、まだ表示されています。

助けてください

 /// <summary>
        /// Adds source list and content type.
        /// </summary>
        /// <param name="currentWeb"></param>
        private void AddSourcesList(SPWeb currentWeb)
        {
            currentWeb.AllowUnsafeUpdates = true;

            #region Add Source content type.
            if(currentWeb.ContentTypes[SponsoringCommon.Constants.CONTENTTYPES_SOURCES_NAME] == null)
            {
                #region Hides title column
                    currentWeb.Lists.Add(SponsoringCommon.Constants.LISTNAMES_SOURCES_NAME, string.Empty, SPListTemplateType.GenericList);
                    SPList sourceList = currentWeb.Lists.TryGetList(SponsoringCommon.Constants.LISTNAMES_SOURCES_NAME);
                    SPField titleField = sourceList.Fields.GetField("Title");
                    titleField.Required = false;                    
                    titleField.ShowInEditForm = false;
                    titleField.ShowInDisplayForm = false;
                    titleField.ShowInNewForm = false;
                    titleField.Hidden = true;
                    titleField.Update(); 
                #endregion 
4

1 に答える 1

4

コードの残りの部分は見えませんが、同様の問題があり、欠けていた.Update()のはリストと Web です。したがって、あなたの場合、sourceListを更新し、最後にcurrentWebを試してください。

うまくいけば、それはあなたの問題を解決するのに役立ちます.

于 2012-07-25T11:05:25.473 に答える