views:

43

answers:

2

My listview is displaying data for a product item. In my template I want to display data based on the id of a product by calling a function that takes the id as a parameter. How is this done?

A: 

You should be able to do something like this:

<ItemTemplate>
   ...
   ...
   <%# myFunction((int)DataBinder.Eval(Container.DataItem, 'myIdColumn')) %>
   ...
   ...
</ItemTemplate>

You custom function (myFunction() in the example above) should return a string.

womp
+1  A: 

If it is .NET 2.0 or above you can use this:

<ItemTemplate>
   <%# SomeFunction((int)Eval("myIdColumn")) %>
</ItemTemplate>

Note that the SomeFunction must be protected or 'higher' for this to work at all.

edosoft