views:

404

answers:

2

Hi,

normally when i want to dislplay the value of a dataitem in a repeater, i use this:

<%#Eval("contact") %>

but now i want to transform the value of this field (contact) in a codebehind function, so i tried this:

<%= ShowcontactInfo(Eval("Contact")) %>

but then i get the exception (at runtime):

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

What can i do?

Michel

+3  A: 

Does this not work?

<%# ShowcontactInfo(Eval("Contact")) %>

Note that Eval returns an object, so your method ShowcontactInfo either needs to aceept an object, or you need to use a cast.

<%= is a shortcut for Response.Write, and is not the same as thnhe databinding syntax <%#

Kragen
+1 for the 'object' info, and the answer is also correct, but Klaus was a little faster (amazing, 2 answers in 1 minute) so i'll give him the mark-as-answer.
Michel
+1  A: 

Can't you do it like this? : <%# ShowcontactInfo(Eval("Contact")) %>

klausbyskov
me feels like beginner.... that indeed works. Thanks!
Michel