ASP.NET:对象在评估和演示 [英] ASP.NET: Objects in Eval
问题描述
如果我有我的数据源即对象
If I have objects in my DataSource i.e
.Select(e => new { Foo = new { Bar = "HelloWorld" }, Price = 12345 }
我怎么引用这个使用eval?
how do I reference this using Eval?
<%# Eval("Foo.Bar") %>
不起作用? (EVAL(价格)确实....)
doesn't work? (Eval("Price") does....)
反正有做&LT;%#的eval(的eval(富),酒吧)%>什么
Is there anyway to do <%# Eval(Eval("Foo"),"Bar") %> or something ?
推荐答案
如果这是引用数据绑定控件,你要绑定的一些列表或匿名IQueryable的,你应该能够使用的eval(酒吧)
,因为foo是在绑定已经指出。
If this is in reference to a DataBound control where you're binding to some List or anonymous IQueryable, you should be able to use Eval("Bar")
since the Foo is already indicated in the bind.
编辑:
看着你的更新,如果你想使用&LT;%#%&GT;
符号,您可能能够通过使用逃脱它的Container.DataItem
。
Looking at your update, if you want to use the <%# %>
notation, you might be able to get away with it by using Container.DataItem
.
<%# ((Foo)Container.DataItem)["Bar"] %>
这篇关于ASP.NET:对象在评估和演示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!