中继器数据绑定中的中继器(无回发)
对于解决方案,我不能使用任何回发方法,因为这都是通过ajax完成的。该解决方案需要在asp.net代码中实现。
我有一个 List
,其中包含链接列表(List)
,我需要所有链接来绑定重复信息,例如页面标题、id ,网址。这是我现在的中继器。
<div id="result">
<asp:Repeater runat="server" id="results">
<Itemtemplate>
<asp:Repeater runat="server" datasource='<%# Eval("Links") %>'>
<Itemtemplate>
<tr class="gradeX odd">
<td><%# Eval("Id") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("Title") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("Url") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("URL") %></td>//Property of Link
<td><%# Eval("URLType") %></td> //Property of Link
<td><%# Eval("URLState") %></td> //Property of Link
</tr>
</Itemtemplate>
</asp:Repeater>
</Itemtemplate>
</asp:Repeater>
</div>
当然这不起作用,我该怎么做呢?
感谢您的帮助!
For the solution, I cannot use any postback methods, because this is all working through ajax. The solution need to be implemented in the asp.net code.
I have a List<WebPage>
that contains a list of Links (List<Link>)
and I need for all the links to bind repetitive information such as page title, id, url. Here is my current repeater.
<div id="result">
<asp:Repeater runat="server" id="results">
<Itemtemplate>
<asp:Repeater runat="server" datasource='<%# Eval("Links") %>'>
<Itemtemplate>
<tr class="gradeX odd">
<td><%# Eval("Id") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("Title") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("Url") %></td> //property of WebPage (part of results repeater)
<td><%# Eval("URL") %></td>//Property of Link
<td><%# Eval("URLType") %></td> //Property of Link
<td><%# Eval("URLState") %></td> //Property of Link
</tr>
</Itemtemplate>
</asp:Repeater>
</Itemtemplate>
</asp:Repeater>
</div>
of course this doesnt work, how can i do this?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您在这里试图解决的问题是如何在嵌套对象中包含多个级别的属性 - 一些属性来自顶层,但其他属性来自较低级别。实现此目的的一种简单方法是将内部集合转换为新类型,其中包含您需要的所有属性的组合。
下面的代码示例使用
IEnumerable.Select
演示了此技术 和 C# 匿名类来创建一个新类:I'm assuming the problem you're trying to solve here is how to include properties from multiple levels in a nested object-- some properties from the top level but other properties from the lower level. One easy way to do this is to transform the inner collection into a new type which contains a mix of all the properties you need.
Here's a code sample illustrating this technique using
IEnumerable.Select
and C# Anonymous Classes to create a new class: