Bogdan Verbenets
Bogdan Verbenets

Reputation: 26936

specify function in ASP.NET binding expression

A repeater control is bound to array of items with class that has boolean IsClosed property. I want to display one picture if it is true, and another if it is false. I can't just add a property to my item class that would return the exact path to the image, so I need some sort of function that would process IsClosed property for each data item inside Repeater's DataSource. But how do I write a proper binding expression? Code like:

<%# Eval("IsClosed") %>

works, but code like:

<%# GetIconPath(Eval("IsClosed")) %>

doesn't work.

Upvotes: 0

Views: 311

Answers (1)

John Pick
John Pick

Reputation: 5650

Does this work?

<%# GetIconPath((bool)Eval("IsClosed")) %>

Upvotes: 1

Related Questions