Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 08, 2010 02:05 PM by PeteNet
Apr 08, 2010 09:42 AM|LINK
I have a problem here.In my database I store member status in 1 and 0, when it come to my gridview I need change 1 and 0 to active and inactive. My company is using Linq, so I must follow. I wrote in this style, I calling a changeToWord() function to change
1 and 0 to active and inactive.
var q=from a in db.members
It compiles with no error, but when I execute the page, it prompt out a error message to me. Thanks.
Apr 08, 2010 12:14 PM|LINK
but when I execute the page, it prompt out a error message to me.
could you tell us what is the error you are getting?
Apr 08, 2010 12:38 PM|LINK
the error msg is "Could not translate expression 'value(ASP.gui_member_List_aspx).changeToWord(a.Status)' into SQL and could not treat it as a local expression."
Apr 08, 2010 02:05 PM|LINK
you could do it inline, example:
var q= from a in db.members
status= a.status == 1 ? "Active" : "InActive",
statusFromFunction = ChangeStatus(a.status)
public string ChangeStatus(object obj)
string retVal = String.Empty;
if (obj!= null)
if (obj.ToString() == "1")
retVal = "Active";
retVal = "InActive";
Linq to SQL