ad <ad@wfes.tcc.edu.tw> wrote:
I convert the field to a template column and then use a tmeplate expression
like this:
<%# (DataBinder.Eval(Container, "DataItem.SexID"))=="1" ? "Male":"Female"%>
Why the value always equal Female
DataBinder.Eval (object, string) is an expression of type object, so
you're performing a reference identity comparison against the string
literal "1". If you use
"1".Equals(DataBinder.Eval (Container, DataItem.SexID"))
?"Male":"Female"
you may well find it works. Or not, depending on whether the evaluation
actually returns a string or not...
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too