sharepoint类型转换

sharepoint学习汇总

http://blog.csdn.net/qq873113580/article/details/20390149 

 

 

         r[col.ColumnName] = GetType(projectList.Fields[col.ColumnName].Type, projectItem[col.ColumnName].ToString(), spWeb);
                   

        public static string  GetType(SPFieldType fieldType, string fieldValue, SPWeb spWeb)
        {

            if (fieldValue != "")
            {
                if (fieldType == SPFieldType.User)
                {
                    string tempUser = string.Empty;
                    SPFieldUserValueCollection spFieldUserValueColl = new SPFieldUserValueCollection(spWeb, fieldValue);
                    foreach (SPFieldUserValue userValue in spFieldUserValueColl)
                    {
                        tempUser += userValue.User.Name + " ";
                    }
                    fieldValue = tempUser;
                }
                else if (fieldType == SPFieldType.DateTime)
                {
                    fieldValue = DateTime.Parse(fieldValue).ToString("yyyy-MM-dd");
                }
                else if (fieldType == SPFieldType.Lookup)
                {
                    SPFieldLookupValue sPFieldLookupValue = new SPFieldLookupValue(fieldValue);
                    fieldValue = sPFieldLookupValue.LookupValue;
                }
                return fieldValue;
            }
            else
            {
                return "";
            }
        }

发布了230 篇原创文章 · 获赞 184 · 访问量 35万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览