zoukankan      html  css  js  c++  java
  • 深入浅出SharePoint——计算列如何使用Item的ID

    问题描述:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.SharePoint;
     
    namespace NCR
    {
        class NCRListEventHandler: SPItemEventReceiver
        {
            /// <summary>
            /// Update NCRPrint calculated column so ID column is not blank. Without this new items have ID empty in NCRPrint column
            /// </summary>
            /// <param name="properties"></param>
            public override void ItemAdded(SPItemEventProperties properties)
            {
                UpdateNCRPrintField(properties);
            }
     
            /// <summary>
            /// Without this the ID in the calculated column after update becomes 0 or empty
            /// </summary>
            /// <param name="properties"></param>
            public override void ItemUpdated(SPItemEventProperties properties)
            {
                UpdateNCRPrintField(properties);
            }
     
            private void UpdateNCRPrintField(SPItemEventProperties properties)
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(properties.SiteId))
                    {
                        using (SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
                        {
                            SPField fldNCRPrint = web.Lists.GetList(properties.ListId, false).Fields.GetFieldByInternalName(Helper.FieldNames.NCRPrint.ToString());
                            fldNCRPrint.Update(true);
                        }
                    }
                });
            }
        }
    }
  • 相关阅读:
    差分约束
    POJ 2449 Remmarguts' Date[k短路]
    K短路
    hdu4034 Graph(floyd)
    hdu2089不要62(数位dp)
    POJ3468 A Simple Problem with Integers ( 线段树)
    POJ3255:Roadblocks(次短路 SPFA+A星)
    usaco2.1Ordered Fractions( 枚举, 数学)
    hdu1565方格取数(1) (状态压缩dp)
    poj3259 Wormholes(spfa)
  • 原文地址:https://www.cnblogs.com/mingle/p/2873169.html
Copyright © 2011-2022 走看看