<asp:Repeater ID="rpt1" runat="server" onitemdatabound="rpt1_ItemDataBound">         <HeaderTemplate> <table width=400 cellpadding=0 cellspacing=0></HeaderTemplate>            <ItemTemplate><tr>         <td><font color=black style="font-size: medium; color: #000000"><b><%# DataBinder.Eval(Container.DataItem,"CategoryName")%></b></font></td></tr>                  <tr><td align=right>                         <asp:Repeater ID="rpt2" runat="server">                             <HeaderTemplate>                                <table width=360 align=center cellpadding=0 cellspacing=0>                             </HeaderTemplate>                                  <ItemTemplate>                                       <tr>                                         <td align=left width=200 style="color: #000080; text-decoration: none; font-family: Calibri;"><font color=black>+</font><%# DataBinder.Eval(Container.DataItem,"CategoryName")%></td>                                         <td width=80 align=center>                                             <a href=ProductSort.aspx?type=1&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>修改</a></td>                                                                                   <td width=80 align=center>                                           <a href=ProductSort.aspx?type=2&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>删除</a>                                         </td>                                       </tr>                                       <tr>                                          <td align=right colspan=3>                                               <asp:Repeater ID="rpt3" runat="server">                                                  <HeaderTemplate>                                                     <table width=320 align=center cellpadding=0 cellspacing=0>                                                  </HeaderTemplate>                                                     <ItemTemplate>                                                        <tr>                                                           <td align=left width=160 style="color: #000080; text-decoration: none; font-family: Calibri;"><font color=black>-</font><%# DataBinder.Eval(Container.DataItem,"CategoryName")%></td>                                                           <td width=80 align=center>                                                               <a href=ProductSort.aspx?type=1&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>修改</a>                                                           </td>                                                            <td width=80 align=center>                                                                <a href=ProductSort.aspx?type=2&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>删除</a>                                                           </td>                                                        </tr>                                                     </ItemTemplate>                                                  <FooterTemplate>                                                     </table>                                                  </FooterTemplate>                                               </asp:Repeater>                                                                                   </td>                                       </tr>                                       <tr>                                                                               </tr>                                  </ItemTemplate>                             <FooterTemplate>                                </table>                             </FooterTemplate>                         </asp:Repeater>                    </td>                 </tr>                 <td height=15px; style="border-style:none;"> </td>            </ItemTemplate>            <FooterTemplate>             </table>            </FooterTemplate>         </asp:Repeater>

后台。aspx.cs

protected void rpt1_ItemDataBound(object sender, RepeaterItemEventArgs e)     {         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)         {             Repeater rpt2 = (Repeater)e.Item.FindControl("rpt2");             //找到分类Repeater关联的数据项             DataRowView rowv = (DataRowView)e.Item.DataItem;             rpt2.ItemDataBound += new RepeaterItemEventHandler(rpt2_ItemDataBound); //最最重要的一句             //提取分类ID             cid = Convert.ToInt32(rowv["ID"]);             //根据分类ID查询该分类下的产品,并绑定产品Repeater             rpt2.DataSource = Pcategory.getP(cid);//数据绑定             rpt2.DataBind();         }     }     protected void rpt2_ItemDataBound(object sender, RepeaterItemEventArgs e)     {         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)         {             Repeater rpt3 = (Repeater)e.Item.FindControl("rpt3");             //找到分类Repeater关联的数据项             DataRowView rowvv = (DataRowView)e.Item.DataItem;             //提取分类ID             cid2 = Convert.ToInt32(rowvv["ID"]);             //根据分类ID查询该分类下的产品,并绑定产品Repeater             rpt3.DataSource = getrpt3(cid, cid2);//数据绑定             rpt3.DataBind();         }     }

转载自:http://www.aspnetjia.com

repeater三级嵌套绑定的更多相关文章

  1. 在Repeater中嵌套使用Repeater

    在一般的网站中浏览类别的用户控件通常都位于大多数 ASP.NET 页的左边,它使用户能够按类别快速的查找产品.最近遇到一个客户,因为在他网站上展示的产品并不多,所以要求在原有类别浏览的基础上将产品也加 ...

  2. 手机web开发Repeater四层嵌套

    最近有朋友想让我给他做个手机上页面,页面功能是显示省--市--区--门店信息,这种层级关系的数据,首先来看看效果: 我想现在的手机都是智能机了对于普通的asp.net页面开发应该没什么两样,不过最终开 ...

  3. (转)在Repeater中嵌套使用Repeater

    在一般的网站中浏览类别的用户控件通常都位于大多数 ASP.NET 页的左边,它使用户能够按类别快速的查找产品.最近遇到一个客户,因为在他网站上展示的产品并不多,所以要求在原有类别浏览的基础上将产品也加 ...

  4. DataList嵌套绑定例子

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataList控件.asp ...

  5. QFramework 使用指南 2020 (四):脚本生成(2)ViewController 与 ViewController 嵌套绑定

    在上一篇,我们学习了,脚本生成的基本使用. 在这一篇,我们试着深入,聊聊脚本生成给我们带来的便利. 脚本生成的便利 首先,我们要知道,在 Unity 的游戏世界中都是以 GameObject 为单位的 ...

  6. 关于Repeater嵌套绑定的问题

    前台代码: <div id="firstpane" class="menu_list">                <asp:Repeat ...

  7. Repeater嵌套绑定Repeater

    前台Html代码 <asp:Repeater runat="server" ID="rpList" OnItemDataBound="rpLis ...

  8. 转:Repeater嵌套绑定Repeater以及内层调用外层数据

    <table border=" style="margin-bottom: 5px" width="100%"> <asp:Repe ...

  9. DataList与Repeater嵌套绑定

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs&quo ...

随机推荐

  1. Linux的原子操作与同步机制

    Linux的原子操作与同步机制   .进程1执行完“mov eax, [count]”后,寄存器eax内保存了count的值0.此时,进程2被调度执行,抢占了进程1的CPU的控制权.进程2执行“cou ...

  2. Mycat 月分片方法

    概述 本篇文章主要介绍Mycat以月进行分片的方法,包括配置方法.注意事项等. mycat版本:1.4 数据节点:dn1,dn2,dn3 架构:主从 配置  创建测试表 CREATE TABLE `t ...

  3. 深入挖掘.NET序列化机制——实现更易用的序列化方案

    .NET框架为程序员提供了“序列化和反序列化”这一有力的工具,使用它,我们能很容易的将内存中的对象图转化为字节流,并在需要的时候再将其恢复.这一技术的典型应用场景包括[1] : 应用程序运行状态的持久 ...

  4. 分享自己写的JS版日期格式化和解析工具类,绝对好用!

    前言 本来想模仿Java里面的SimpleDateFormat()对象的,但是感觉这样用起来不方便,所以还是直接写成单独的方法算了. 原文链接 日期格式化 使用说明 formatDate(date, ...

  5. Leetcode 刷题计划

    Two Sum    21.4%    Medium Given an array of integers, return indices of the two numbers such that t ...

  6. 花一分钟来看看Worktile是如何为团队协作而生的

    团队协作,我们想的更深.更远.更多,花一分钟来看看我们特别奉献的故事,然后去注册一个账号,邀请小伙伴一起来工作,你会体会Worktile才是真正懂你的协作方式.

  7. css浮雕效果

    浮雕效果 今天看百度地图看到了一个效果 感觉这个效果用在网页上应该蛮赞的,于是就学习了一下 浮雕效果需要用到伸缩盒的知识(flex) flex在chrome是完全支持的,要加-webkit-前缀,其他 ...

  8. Lua table之弱引用

    Lua采用了基于垃圾收集的内存管理机制,因此对于程序员来说,在很多时候内存问题都将不再困扰他们.然而任何垃圾收集器都不是万能的,在有些特殊情况下,垃圾收集器是无法准确的判断是否应该将当前对象清理.这样 ...

  9. MVC validate.js下使用 ajaxSubmit

    首页定义验证实体 using System.ComponentModel.DataAnnotations; using System.Web.Mvc; namespace MvcApplication ...

  10. C#设计模式-享元模式

    在软件开发过程,如果我们需要重复使用某个对象的时候,如果我们重复地使用new创建这个对象的话,这样我们在内存就需要多次地去申请内存空间了,这样可能会出现内存使用越来越多的情况,这样的问题是非常严重,然 ...