i have an object that as a parameter bool?
i need to show it on a repeater.
<%# Eval("LS_Body_Connection") %>
i create a class
public static class BooleanExtensions
{
public static string ToYesNoString(this bool value)
{
return value ? Resources.Yes : Resources.No;
}
}
how to use it on the repeater?
i try
((bool)Eval("LS_Body_Connection")).ToYesNoString()
but it's not recognaize
'bool' does not contain a definition for 'ToYesNoString' and no extension method 'ToYesNoString' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?)
in the cs of the page i can call the extension method
when i add
<%@ Import Namespace="IDD.App_Code" %>
i get The call is ambiguous between the following methods or properties: 'IDD.App_Code.BooleanExtensions.ToYesNoString(bool?)' and 'IDD.App_Code.BooleanExtensions.ToYesNoString(bool?)'
try ((bool)Eval("LS_Body_Connection")).ToYesNoString()
And you need to import the namespace like below as Claudio's Answer
<%@ Import Namespace="My.Namespace.Containing.MyExtensions.Class" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With