Click here to Skip to main content
15,936,850 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all!!

i have taken an item template inside a gridview. I have bind it to a column name status which has values either 0 or 1. Now i am using Eval() with ternary operator to set the text of the label inside the item template field. But it's always showing me the False condition. Column has both 0 and 1's DataType is int Plz help Me out!!

<asp:TemplateField HeaderText="Status">
           <asp:Label id="lblStatus" runat="server" Text='<%#Eval("Status")=="1"?"ClubMember":"Free User" %>'></asp:Label>


1 solution

Try this
<%#Eval("Status").ToString()=="1" ? "ClubMember" : "Free User" %>

Using Eval[^]
Share this answer
ujjwal uniyal 8-Dec-11 3:17am    
Thanks for the help sir. It worked.. :)
thatraja 8-Dec-11 3:26am    
kiranpylla 28-Mar-12 23:58pm    
Thanks, it helped me. So we need to keep ToString() after #Eval("Status").

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900