ASP.NET邦定数据“<%#Eval("Sex")%>”运用三元运算符:
<%#(Eval("Sex", "{0}") == "") ? "男" : "女"%>
<%#(Convert.ToInt32(Eval("NowDate","{0}"))>)?Convert.ToInt32(Eval("NowDate"))/+"小时前":Eval("NowDate").ToString()+"分钟前"%><span class="style3"> 来自优酷网</span></td>
ImageUrl='<%#(Eval("Use_Pic", "{0}").ToString() =="Null")? "Head/head.png" : Eval("Use_Pic")%>'
数据绑定时多余的长度用“……”代替:
<asp:LinkButton ID="linkMessage" ForeColor="Black" runat="server" Text='<%#Eval("NewsTitle").ToString().Length>10?Eval("NewsTitle").ToString().Substring(0,10)+"……":Eval("NewsTitle")%>'/>
Eval绑定方法:
<asp:TemplateField HeaderText="付费状态">
<ItemTemplate>
<asp:Label runat="server" ID="lbPayStatus" Text='<%#BLL.OrderBLL.GetPayStatus(Convert.ToInt32(Eval("id"))) %>'/>
</ItemTemplate>
</asp:TemplateField>
多条件绑定:
<asp:TemplateField HeaderText="一审结果">
<ItemTemplate>
<%#Eval("hg_A").ToString()==""?"通过":Eval("hg_A").ToString()==""?"不通过":""%>
</ItemTemplate>
</asp:TemplateField>