当前位置: 代码迷 >> ASP.NET >> 前台怎么绑定特殊数据的
  详细解决方案

前台怎么绑定特殊数据的

热度:7700   发布时间:2013-02-25 00:00:00.0
前台如何绑定特殊数据的?
唉,标题表达不出来意思. 听我解释.

是这样的.数据库中有一字段[pUrl]
里面的数据有:
[../UpLoad]
[../UpLoad]
[../UpLoad]
[no]
[../UpLoad]
[no]
[../UpLoad]
[../UpLoad]这八个数据
请问,我在后台DataBind()之后,我在前台(aspx)怎么把凡是数据库中是[no]的在前台都以[../no]显示?
谢谢!


------解决方案--------------------------------------------------------
1.查询时替换返回
select rename =
case [pUrl]
when '[no] ' then '[../no]'
else [pUrl] end 
from table

2.绑定到数据控件时转换

<%#DataBinder.Eval(Container.DataItem, "pUrl").tostring() == "[no]" ? "[../no]" : DataBinder.Eval(Container.DataItem, "pUrl").tostring() %> 


方法1是推荐方法!
  相关解决方案