日期:2014-05-18  浏览次数:20481 次

前台如何绑定特殊数据的?
唉,标题表达不出来意思. 听我解释.

是这样的.数据库中有一字段[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是推荐方法!