我在 ac# aspx 页面中有以下代码:
<ItemTemplate>
<a <% if(((Dictionary<string, string>)Container.DataItem)["type"]==Session["type"]){%> class="active"<%}%>
此代码导致以下错误。
Compiler Error Message: CS0117: 'System.ComponentModel.Container' does not contain a definition for 'DataItem'
为什么会这样,我怎样才能做出使用的条件语句Container.DataItem
?Container.DataItem
在 a 中使用时效果很好,<%# %>
但是将if
语句放入<%# %>
会导致以下错误:
Compiler Error Message: CS1518: Expected class, delegate, enum, interface, or struct