Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control

前端 未结 4 1566
借酒劲吻你
借酒劲吻你 2020-11-30 07:33

I am getting the following error

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

<
4条回答
  •  醉话见心
    2020-11-30 07:46

    Its too late but i would like to answer it in my way, what i used to achieve it:

    <%# Eval("Message").toString()== HttpContext.Current.Profile.UserName)?"" :""%>
    

    Now this will only show image button if Message is equal to username.

    This might help any one else in same situation.

    In my situation i needed to check null and empty string...so i implemented like this below:

    <%# Eval("DateString")!= null && Eval("DateString")!= ""? ""+Eval("DateString") + "":"" %>
    

    Thanks

提交回复
热议问题