DataBinder.Eval() in C# Question

  • Thread starter Thread starter Patrick Olurotimi Ige
  • Start date Start date
P

Patrick Olurotimi Ige

If have i a funtion below:-
Protected Function CheckUnit(Units As Object) As String

'-----------------------------------------
' If the Units returned equals to Zero,
' a message of "Out of Units" will be displayed.
' Otherwise, displayed the original value
'-----------------------------------------

If Integer.Parse(Units) = 0 Then
Return "Out Of Units"
Else
Return Units.ToString()
End If

End Function

I use :- <%# CheckUnit(Container.DataItem("Units")) %>
to display the value of the function.
But in C sharp it gives error so i used

<%# DataBinder.Eval(Container.DataItem, "Units") %>
and it works!!

whats the right code when using C# to dislpay the value using

<%# DataBinder.Eval(Container.DataItem, "Units") %>
with the CheckUnit Function???
 
What is the error that occurred?

Try changing your CheckUnits to a public method.

bill
 
DataBinder.Eval also returns a string, so you might change your method
signature.

bill
 
Back
Top