如何通过DNN中的代码创建配置文件属性(DotNetNuke)?
我试过这段代码:
DotNetNuke.Entities.Profile.ProfilePropertyDefinition def =
DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(this.PortalId, "Level");
if (def != null)
{
def.DataType = 10;
def.Length = 40;
def.PropertyValue = "Level";
def.PropertyName = "Level";
oUser.Profile.ProfileProperties.Add(def);
}
oUser.Profile.SetProfileProperty("Level", ddlLevel.SelectedItem.Text.ToString().Trim());
DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(oUser, oUser.Profile.ProfileProperties);
但它不起作用,请帮助我找到合适的解决方案。
答案 0 :(得分:6)
尝试使用此代码添加配置文件属性:
if (DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(this.PortalId, "Level") == null)
{
DotNetNuke.Entities.Profile.ProfileController.AddPropertyDefinition(
new DotNetNuke.Entities.Profile.ProfilePropertyDefinition(this.PortalId)
{
PropertyName = "Name",
DataType = 10,
...
});
}