repeat绑定
<%# CheckHouseType(DataBinder.Eval(Container.DataBind,"Ctype")) %>
Ctype为1时是"AAAA",2时是"BBBB",3时是"CCCC"protected void CheckHouseType(object myTid)
{
if (myTid.ToString() == "1")
{
Response.Write("AAAAA");
}
else if (myTid.ToString() == "2")
{
Response.Write("BBBBB");
}
else {
Response.Write("CCCCC");
}
}
提示出错:
System.Web.UI.DataBinder.Eval(object, string)”最匹配的重载方法具有一些无效参数请指点,谢谢
<%# CheckHouseType(DataBinder.Eval(Container.DataBind,"Ctype")) %>
Ctype为1时是"AAAA",2时是"BBBB",3时是"CCCC"protected void CheckHouseType(object myTid)
{
if (myTid.ToString() == "1")
{
Response.Write("AAAAA");
}
else if (myTid.ToString() == "2")
{
Response.Write("BBBBB");
}
else {
Response.Write("CCCCC");
}
}
提示出错:
System.Web.UI.DataBinder.Eval(object, string)”最匹配的重载方法具有一些无效参数请指点,谢谢
protected string CheckHouseType(object myTid)
{
if (myTid.ToString() == "1")
{
return "AAAA"; }
else if (myTid.ToString() == "2")
{
return "BBBBB";
}
else {
return "CCCCC";
}
}
另外,不晓得为什么要用Response.Write
方法修改为:protected string CheckHouseType(object myTid)
{
if (myTid.ToString() == "1")
{
return "AAAA"; }
else if (myTid.ToString() == "2")
{
return "BBBBB";
}
else {
return "CCCCC";
}
}
protected string CheckHouseType(string mystr)
{
switch (mystr.ToString())
{
case "1":
return "住宅";
break;
case "2":
return "商铺";
break;
case "3":
return "写字楼";
break;
case "4":
return "厂房";
break;
}
}
[/code]<%# CheckHouseType(Eval("Ctype").ToString())%>当我把switch语句换成if else时就正确了,而使用switch语句时就提供,[color=#FF0000]/.CheckHouseType(string)”: 并非所有的代码路径都返回值[color]
我是小菜鸟,望各位朋友不要见怪~~还请指点,再谢感~~~~