Why all Female

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

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


(This method is from Rick Strahl)
 
Very funny, however your reply did nothing to help the OP. Perhaps you can
demostrate your assertion by posting an 'Answer' which may help the OP?


--
OHM ( Terry Burns )

http://TrainingOn.net
 
Ad,

Why don't you change it in your program to:
<%# (DataBinder.Eval(Container, "DataItem.SexID")).ToString()%>

Than you would see it in my opinion

Although woman are of course superior to man, should this not a reason that
they can do it without them.

Cor
 
This is beecause the value is never "1". If it's a boolean item in the
dataset the response is probably "true" or "false" but don't rule out the
possibilities of "yes" or "no".

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
ad said:
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...
 
Back
Top