需要在前台datalist里面写个IF语句?
在绑定字段ImageUrl (路径) 这个字段的时候 如果从数据库里面取出来的字段内容包含了 "HTTP "字段 就显示这个字段内容 如果没有包含就显示另外一个路径(UploadImages/ "Eval( "ImageUrl ")%> )
如:
<asp:DataList ID= "DataList1 " runat= "server " RepeatColumns= "4 " RepeatDirection= "Horizontal " RepeatLayout= "Flow ">
<ItemTemplate>
<table border= "0 " cellspacing= "5 " cellpadding= "0 " width= "100% ">
<tr>
<td> //下面这个地方该怎么写(要求是要在前台改 后台改不方便)
<img src= <%# Eval( "ImageUrl ").ToString().ToUpper().IndexOf( "HTTP ") > -1 ? Eval( "ImageUrl ") : "UploadImages/ "Eval( "ImageUrl ")%> " width= "80 " height= "77 "> </a> </td>
<td width= "41% "> <b> <%# Eval( "Name ") %> / <%# ChangeMercID(Eval( "MercID ").ToString())%> </b> <br>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
------解决方案--------------------我不清楚什么叫前台后台,理解为代码分离吧....
三目是 val = truefalse ? true : false 吧?
不熟悉...
<%#=(Eval( "ImageUrl ").ToString().ToUpper().IndexOf( "HTTP ") > -1 ? Eval( "ImageUrl ") : "UploadImages/ "+Eval( "ImageUrl ").ToString())%>
这样?
------解决方案-------------------- <asp:DataList ID= "DataList1 " runat= "server " RepeatColumns= "4 " RepeatDirection= "Horizontal " RepeatLayout= "Flow ">
<ItemTemplate>
<table border= "0 " cellspacing= "5 " cellpadding= "0 " width= "100% ">
<tr>
<td>
<img src= ' <%# Eval( "ImageUrl ").ToString().ToUpper().IndexOf( "HTTP ") > -1 ? Eval( "ImageUrl ").ToString() : "UploadImages/ " + Eval( "ImageUrl ").ToString() %> ' width= "80 " height= "77 "> </a> </td>
<td width= "41% "> <b> <%# Eval( "Name ") %> / <%# ChangeMercID(Eval( "MercID ").ToString())%> </b> <br>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
------解决方案--------------------先在后台定义一个方法
public string GetUrl(string str)
{
if()