当前位置:Gxlcms > 数据库问题 > Reapter控件的特殊使用:使用EVAL调取asp:Repeater里面绑定的值来进行判断 根据从数据库获取的数据进行判断 ,进而显示成想要的内容

Reapter控件的特殊使用:使用EVAL调取asp:Repeater里面绑定的值来进行判断 根据从数据库获取的数据进行判断 ,进而显示成想要的内容

时间:2021-07-01 10:21:17 帮助过:4人阅读

1.这个判断的过程你可以写在后台,如先在后台写一个public类型的方法:
public bool CheckAduit(string code)
{
//根据你传入的code来判断,并返回true或者false
}

然后绑定这里写:
<%#CheckAduit(Convert.ToString(Eval(‘isaduit‘)))%>

2.直接写 三元表达式
<%# Convert.ToString(Eval(‘isaduit‘))=="0"?"是"?"否"%>

3.在这个Repeater的DataRowBind事件里进行替换。
<td><% string color = Eval("color").ToString();

switch (color)
{
case "4a1":
Response.Write("<font color=‘#5f1a1f‘>" + Eval
("smallType") + "<br />" + Eval("otherColor") + "</font>");
break;
case "4a2":
Response.Write("<font color=‘#ba6525‘>" + Eval
("smallType") + "<br />" + Eval("otherColor") + "</font>");
break;
case "4a3":
Response.Write("<font color=‘#bd8256‘>" + Eval
("smallType") + "<br />" + Eval("otherColor") + "</font>");
break;
case "4a8":
Response.Write("<font color=‘#980808‘>" + Eval
("smallType") + "<br />" + Eval("otherColor") + "</font>");
break;
case "4a11":
Response.Write("<font color=‘#791418‘>" + Eval
("smallType") + "<br />" + Eval("otherColor") + "</font>");
break;
case "4a14":
Response.Write("<font color=‘#a32496‘>" + Eval
("smallType") + "<br />" + Eval("otherColor") + "</font>");
break;
default:
Response.Write("" + Eval("smallType") + "<br />" +
Eval("otherColor") + "");
break;
}
%></td>




Reapter控件的特殊使用:使用EVAL调取asp:Repeater里面绑定的值来进行判断 根据从数据库获取的数据进行判断 ,进而显示成想要的内容

标签:

人气教程排行