I need to get User custom field value by userid in ascx transformation.
Code like <%# GlobalObjects.Users.Where("UserID="+ToInt( Eval("UserId"), 0 )).GetValue("my_field") %> does not work.
<%# GlobalObjects.Users.Where("UserID="+ToInt( Eval("UserId"), 0 )).GetValue("my_field") %>
How to get user custom field value by userid in ascx transformation?
Your code is for Text/XML transformation except for that note from Roman. You need this one:
<%# CMS.Membership.UserInfoProvider.GetUserInfo(CMS.Helpers.ValidationHelper .GetInteger(Eval("UserId"),0)).GetValue("my_field") %>
Where returns a collection, so you can't use GetValue with it. You need something like FirstOrDefault, which will return you single object.
Try this:
CMS.Membership.UserInfoProvider.GetUserInfo(ValidationHelper.GetInteger(Eval("UserID"), -1)).GetStringValue("YourColumn", "")
it returns
error CS0103: The name 'GlobalObjects' does not exist in the current context
So I don't think that error is in FirstOrDefault
Please, sign in to be able to submit a new answer.