如何利用 Substring 截取 <%# Eval("val") %>中的字符? 比如我想从<%# Eval("val") %>中截取它的前5位字符,该怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%# (Eval("val")).ToString().Substring(0,5) %> <%# Eval("val").Tostring().Substring(0,4) %> 谢谢大家的关注,另外截取的目的只为实现以下功能,我这样写好像不对,请在帮我看看!---Visible='<%# (Eval('r_Type')).Tostring().Substring(0,5)=="image"?false:true %>' 可以在后台加个方法。来处理这个字符串 <asp:Label ID="lblScoreType" runat="server" Text='<%# FormatType(DataBinder.Eval(Container.DataItem,"ScoreType").ToString()) %>'></asp:Label> public string FormatType(string ScoreType) { string[] type; string showType = ""; string[] types = ScoreType.Split('+'); for (int i = 0; i < types.Length; i++) { type = types[i].Split('*'); showType += GetTypeNameAsID(Convert.ToInt32(type[0])); showType += "(" + type[1] + "题*" + type[2] + "分);"; } return showType; } 谢谢大家的关注,另外截取的目的只为实现以下功能,我这样写好像不对,请在帮我看看!---Visible='<%# (Eval('r_Type')).Tostring().Substring(0,5)=="image"?false:true %>' Convert.ToString(Eval('r_Type')).Substring(0,5) <%# (Eval("val")).ToString().Length>5 ? ((Eval("val")).ToString().Substring(0,5)):((Eval("val")).ToString()) %>不判断的话,当字符串不足5个字符,就会发生异常! Visible='<%# (Eval('r_Type')).Tostring().Substring(0,5)=="image"?false:true %>'可以这样写,但是保证r_Type的长度大于等5,否则会象楼说的,出现异常 各位大虾帮个忙哦。。实现新闻浏览上、下篇怎么弄呢? DropDownList 绑定后显示字段内容的问题!在线等,谢谢! 请教一个javascript脚本控制时间倒计时的问题!! 请教有关数据分页的问题,那一种方法更好 有关水晶报表的公式问题,请指教 请问哪里错了啊? 跪求一个关于ASP JSP的问题 如何连接SQL SERVER数据库? 100分征求学习asp.net 的意见和建议? datagrid中的超链接列 嵌套 datalist checkbox 用js 实现 全选 js 传值问题 缺少对象
---
Visible='<%# (Eval('r_Type')).Tostring().Substring(0,5)=="image"?false:true %>'
<asp:Label ID="lblScoreType" runat="server" Text='<%# FormatType(DataBinder.Eval(Container.DataItem,"ScoreType").ToString()) %>'></asp:Label>
public string FormatType(string ScoreType)
{
string[] type;
string showType = "";
string[] types = ScoreType.Split('+');
for (int i = 0; i < types.Length; i++)
{
type = types[i].Split('*');
showType += GetTypeNameAsID(Convert.ToInt32(type[0]));
showType += "(" + type[1] + "题*" + type[2] + "分);";
}
return showType;
}
---
Visible='<%# (Eval('r_Type')).Tostring().Substring(0,5)=="image"?false:true %>'
可以这样写,但是保证r_Type的长度大于等5,否则会象楼说的,出现异常