DataBinder.Eval() in C# Question

  • Thread starter Patrick Olurotimi Ige
  • 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???
 
W

William F. Robertson, Jr.

What is the error that occurred?

Try changing your CheckUnits to a public method.

bill
 
W

William F. Robertson, Jr.

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

bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top