Technical support This forum is closed.
Version 1.x > Technical support > accessing parent object properties from child in transform... View modes: 
User avatar
Member
Member
argodev - 3/3/2006 4:49:03 PM
   
accessing parent object properties from child in transform...
I have created some custom object/document types... and in one case have a model where i have an item, adn then various packages as "children" of teh item... when writing the transform for the child "packages" i'd like to also display the item name/description from the parent... is there an easy way to reference this in the transforms? (ascx)?

User avatar
Guest
admin - 3/5/2006 10:02:41 AM
   
Re: accessing parent object properties from child in transform...
Hello,

Thank you for your message. You can do that by defining your own function in the ProjectFunctions.cs/vb file and using it in the transformation. It will look like this:

static string GetParentValue(object aliasPath, string attributeName)
{
string parentNodePath = Functions.GetTreeProvider().SelectSingleNode(Convert.ToString(aliasPath), TreePathTypeEnum.AliasPath).GetParentPath(TreePathTypeEnum.AliasPath);
TreeNode parentNode = Functions.GetTreeProvider().SelectSingleNode(parentNodePath, TreePathTypeEnum.AliasPath);
return Convert.ToString(parentNode.GetValue(attributeName));
}

Then, you can use the function in your ascx transformation like

<%# ProjectFunctions.GetParentValue(DataBinder.Eval(Container, "DataItem.AliasPath")) %>

Please let me know if you need any help with that.

Best Regards,