Private: MY Note


DataBinder.Eval() in C# Question

Posted in .NET, .NET 2.0 by dev1 on the October 25, 2007

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???

One Response to 'DataBinder.Eval() in C# Question'

Subscribe to comments with RSS or TrackBack to 'DataBinder.Eval() in C# Question'.

  1. Hitesh Agja said,

    on February 21, 2008 on 12:40 pm

    try this man,

    CheckUnit(DataBinder.Eval(Container,”DataItem.Units” ;)

    bye

    Hitesh Agja

Leave a Reply