Say I have this repeater which makes use of a public function called Test in the code-behind.
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("MyCol1")%></td>
<td><%# Eval("MyCol2")%></td>
<td><%# Test((int)Eval("MyCol1"))%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
In my code-behind, I have this function
public string Test (int Value)
{
return "Test"+Value.ToString();
}
This works fine but in my website I will have similar repeaters on various pages and most of them will need to call the Test function. Instead of having it in the code-behind of each web page would it be possible to put it in a public static class and call it directly from the repeater? Something like this (which does not work):
<td><%# MyStaticClass.Test((int)Eval("MyCol1"))%></td>
The only solution I've come up with would be to change the function in the code-behind to:
public string Test (int Value)
{
return MyStaticClass.Test(Value);
}
But it would be neater if I didn't have to put any code in the code-behind of each webpage (ie I would prefer the repeater to call the static function directly).
Any ideas or suggestions?