[英]Error while Embedding Xpath Code and Inline Server Tags
Grid View template field -网格视图模板字段 -
<% if ((Convert.ToInt64(XPath("NoOfGuests")) < 0))
{ %>
<asp:ImageButton ID="imgbtnAddResByList"
runat="server"
ImageUrl="~/images/btn-addResByList.PNG" />
<asp:ImageButton ID="imgbtnCloseResByList"
runat="server"
ImageUrl="~/images/imgdelete.jpg" />
<%} %>
this throws a runtime error "Databinder exception...".这会引发运行时错误“Databinder 异常...”。 I think it is coming because I have not used
#
in inline code.我认为它即将到来是因为我没有在内联代码中使用
#
。 But I dont know how and where.但我不知道如何以及在哪里。 My concern is I dont want to display there two image buttons when XPath("NoOfGuests") < 0 but I dont want to do this in OnDataBound or OnRowCreated because of performance issue.
我担心的是我不想在 XPath("NoOfGuests") < 0 时显示两个图像按钮,但由于性能问题我不想在 OnDataBound 或 OnRowCreated 中执行此操作。 Is there any other way??
有没有别的办法??
Would it work to evaluate the visibility of each button with the condition?在条件下评估每个按钮的可见性是否有效? For instance:
例如:
<asp:ImageButton ID="imgbtnAddResByList" runat="server"
ImageUrl="~/images/btn-addResByList.PNG"
Visible='<%# If((Convert.ToInt64(XPath("NoOfGuests")) < 0), "False", "True") %>' />
<asp:ImageButton ID="imgbtnCloseResByList" runat="server"
ImageUrl="~/images/imgdelete.jpg"
Visible='<%# If((Convert.ToInt64(XPath("NoOfGuests")) < 0), "False", "True") %>' />
Also, it looks like you haven't specified your conditions for your If statement, so if you wanted to stick with what you've got, you might try something like:此外,您似乎还没有为您的 If 语句指定条件,因此如果您想坚持现有的条件,您可以尝试以下操作:
<%# If((Convert.ToInt64(XPath("NoOfGuests")) < 0), "{", "") %>
<asp:ImageButton ID="imgbtnAddResByList"
runat="server"
ImageUrl="~/images/btn-addResByList.PNG" />
<asp:ImageButton ID="imgbtnCloseResByList"
runat="server"
ImageUrl="~/images/imgdelete.jpg" />
<%# If((Convert.ToInt64(XPath("NoOfGuests")) < 0), "}", "") %>
Although to be honest, I don't think that will work.虽然老实说,我认为这不会奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.