0

OK Im at a crossroads with something. Take a gander at the code below. I have a data repeater, and throughout the repeater I want to call GetNavUrl, supplying it with a parameter found in my data I am binding with.

NavigateUrl='<%# GetNavUrl(DataBinder.Eval(Container.DataItem,"ProductCode") %>'

So, for example, I want navigateURL to equal the result of GetNavUrl(123), Any ideas? thx!

1 Answer 1

1

It sounds like you want to do databinding of child objects in your UI? Honestly, in situations like these, I find it much better to avoid doing such binding in the UI (mostly for separation of concerns), and instead do that in the code behind.

myRepeater.ItemCreated += new ItemsCreatedEventHandler(whatever);

Then, in your item created event handler, find your control and assign that data programmatically:

MyBindedObject dataItem = e.Item.DataItem as MyBindedObject;
HyperLink myLink = e.Item.FindControl("myControl") as HyperLink;

if(myLink != null)
   myLink.NavigateUrl = GetNavUrl(dataItem);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Tejs, if I have to I can def do so.. was just hoping to provide some quick databinding to an already existing page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.