Objects in Kentico Repeater Transformation

Mark McKenna asked on July 31, 2015 13:16

I've actually put this in as a support ticket, but as I'm99% sure I'm just being an idiot, I wondered if I would get a faster response here....

I have a custom class in some global code held elsewhere within my Kentico project. I create an instance of this class with a function also held elsewhere..

In my transformation, which is in a repeater with custom query, I want to call this function and then be able to use information within the class to add to the transformation. I’m not explaining this very well, but here is my transformation code…

<%@ Register Src="~/CMSModules/Ecommerce/Controls/ProductOptions/UCShoppingCartItemSelector.ascx" TagName="CartItemSelector" TagPrefix="uc1" %>

<%# Eval("PartNumber") %> <%# combinedProduct.PartNumber %>

The Above works – both lines work. The problem is I need to replace “a1103” with PartNumber – which I guess is not yet databound when I run the code, resulting in the first string parameter of GetCombinedProduct being null/empty.

Pretty sure this is possible, but I've forgotten which order things need to be in!

Cheers

Correct Answer

Mark McKenna answered on July 31, 2015 16:01

Sorted my head out...

script runat="server" public static UCFunctions.CombinedProduct combinedProduct = new UCFunctions.CombinedProduct();
protected override void OnInit(EventArgs e) { string partNumber = Eval("PartNumber",true).ToString(); combinedProduct = UCFunctions.GetCombinedProduct(partNumber,1,true,true,true); } /script

:)

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.