首页 > 代码库 > sharepoint类型转换

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 = http://www.mamicode.com/tempUser;
                }
                else if (fieldType == SPFieldType.DateTime)
                {
                    fieldValue = http://www.mamicode.com/DateTime.Parse(fieldValue).ToString("yyyy-MM-dd");
                }
                else if (fieldType == SPFieldType.Lookup)
                {
                    SPFieldLookupValue sPFieldLookupValue = http://www.mamicode.com/new SPFieldLookupValue(fieldValue);
                    fieldValue = http://www.mamicode.com/sPFieldLookupValue.LookupValue;
                }
                return fieldValue;
            }
            else
            {
                return "";
            }
        }

sharepoint类型转换