码迷,mamicode.com
首页 > 其他好文 > 详细

sharepoint类型转换

时间:2017-05-17 22:14:23      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:date   lan   static   类型   ref   epo   href   log   string   

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

sharepoint类型转换

标签:date   lan   static   类型   ref   epo   href   log   string   

原文地址:http://www.cnblogs.com/jzssuanfa/p/6869599.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!