嵌套Repeater [英] Nested Repeater

查看:149
本文介绍了嵌套Repeater的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要一点比我使用,以更具活力和似乎无法找到挺我需要答案的显示。

I Have a display that needs to be a little more dynamic than what I'm use to and can't seem to quite find the answer I need.

                        Customer a     Customer b     Customer c    (and so on)
  savings with product a

  savings with product b

  (and so on)

我知道总是会有一个最小的一个在每个字段的。有人说使用嵌套中继器或东西。我环顾四周,找不到如何使用嵌套的中继器。我在最后期限并不能真正的东西玩,直到我发现一些作品。

I know there will always be a minimum of one in each field. Someone said use a nested repeater or something. I looked around and couldn't find out how to use a nested repeater. I am on a deadline and can't really play with things until I find something that works.

我应该使用什么ASP的控制做到这一点?一个例子是不错,但我只需要在正确的方向帮助。

What asp control should I use to do this? An example would be nice but I just need help in the right direction.

我使用SQL而是通过链接获取数据。在列表中的数据结束了。

I am using sql but getting the data through link. The data ends up in lists.

感谢您的帮助!

推荐答案

嵌套中继器是pretty容易。只是扔一个在你的ItemTemplate,并在主中继器的OnItemDataBound事件做以下

Nested Repeaters are pretty easy. Just throw one in your ItemTemplate, and in the OnItemDataBound event of your main repeater do the following

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
     DataRowView row = (DataRowView)e.Item.DataItem;

     Repeater nestedRepeater = e.Item.FindControl("NestedRepeater") as Repeater;
     nestedRepeater.DataSource = getSavingsPerCustomer(row["customerID"]);
     nestedRepeater.DataBind();
 }

当外部Repeater的模板有一个客户名称和中继器和内部人有不同的储蓄

Where the template of the outer repeater had a customer name and a repeater and the inner one has the different savings

可能不正确的语法,但你的想法

probably incorrect syntax but you get the idea

<asp:repeater ID="outer">
<HeaderTemplate>
    <div style="float:left">
</HeaderTemplate>
<ItemTemplate>
     Customer: <%= Eval(customer)%><br/>
     <asp:repeater ID="NestedRepeater">
          <ItemTemplate>
          Saving: <%= Eval(saving)%><br/>
          </ItemTemplate>
     </asp:repeater>
</ItemTemplate>
<FooterTemplate>
    </div>
</FooterTemplate>
</asp:repeater>

相似,所以问题:直放站直放站

这篇关于嵌套Repeater的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆