Asp. NET-bonding data "<% #Eval (" Sex ")%>" using ternary operators:
<%# (Eval ("Sex", "{0}") = = "01")? "Male": "Female"%>
<%# (Convert.ToInt32 (Eval ("Nowdate", "{0}")) >60)? Convert.ToInt32 (eval ("Nowdate"))/60+ "Hour Ago": eval ("Nowdate"). ToString () + "minutes ago"%><span class= "Style3" > from Youku </span></td>
Imageurl= ' <%# (Eval ("Use_pic", "{0}"). ToString () = = "Null")? "Head/head.png": Eval ("Use_pic")%> '
The extra length of data binding is replaced by "...":
<asp:linkbutton id= "Linkmessage" forecolor= "Black" runat= "server" text= ' <% #Eval ("Newstitle"). ToString (). Length>10? Eval ("Newstitle"). ToString (). Substring (0,10) + "...": Eval ("Newstitle")%> '/>
Eval Binding method:
<asp:templatefield headertext= "paid status" >
<ItemTemplate>
<asp:label runat= "Server" id= "lbpaystatus" text= ' <% #BLL. Orderbll.getpaystatus (Convert.ToInt32 (Eval ("id")))%> '/>
</ItemTemplate>
</asp:TemplateField>
Multi-Conditional binding:
<asp:templatefield headertext= "First Instance results" >
<ItemTemplate>
<% #Eval ("Hg_a"). ToString () = = "1"? " Pass ": Eval (" Hg_a "). ToString () = = "2"? " Do not pass ":" "%>
</ItemTemplate>
</asp:TemplateField>
Using the ternary operator when binding data using eval ()