使用databinder.eval时,必须使用<%# %>,看MSDN

解决方案 »

  1.   

    使用databinder.eval时,必须使用<%# %>
      

  2.   

    string sDepth = # DataBinder.Eval( Container.DataItem, "Depth" ).ToString();
    加# 后提示错误: CS1040: 预处理器指令必须作为一行的第一个非空白字符出现那我想取得 “Depth”字段的值 并且赋值给变量sDepth  以便于以后的程序调用!?
    //if (sDepth="")
    //    Response.Write("请选择深度");
    //要怎么写?请各位大虾再赐教!  !!  谢谢!!
      

  3.   

    使用databinder.eval时,必须使用<%# %>,看MSDN
      

  4.   

    那有没有别的方法 取得 “Depth”字段的值 !?
      

  5.   

    绑定时这样写:
    <%#getDepth(databinder.item(Depth))%>
    在后台代码中新一个公共函数:
    public function getDepth(sDepth) as string
    if sDepth="" then
     Response.Write("请选择深度");
    end if
    ....'其它代码,包括返回值等.
    end function
      

  6.   

    谢谢pingnt(努力工作为明天)提供方法给我。我可能不只取得一个“Depth”字段值, 可能还要有许许多多字段值要联合起来判断。最好是能在*.aspx页面上直接取得 “Depth”字段的值, 
    有没有实现数据被绑定后,在*.aspx 页面上直接取得 “Depth”字段的值的方法?
      

  7.   

    为什么非要在ASPX端取直啊,一般来讲应在服务器端解决数据处理问题.
    要处理多个字段也可以这样:
    <%#getDepth(container.dataitem("Depth"),container.dataitem("字段1"),container.dataitem("字段2"))%>
    ''对了,前面的回复中此处代码应为container.dataitem,而不是databinder.item,好不意思!
    在后台代码中新一个公共函数:
    public function getDepth(sDepth,变量1,变量2) as string
    if sDepth="" then
     Response.Write("请选择深度");
    end if
    ....'其它代码,包括返回值等.
    end function