<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. [译] 给PHP开发者的PHP源码-第一部分-源码结构

    文章来自:http://www.hoohack.me/2016/02/04/phps-source-code-for-php-developers-ch 原文:http://blog.ircmaxel ...

  2. HTML和CSS经典布局3

    如下图: 需求: 1. 如图 2. 可以从body标签开始. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xht ...

  3. ASP.NET Web API自身对CORS的支持:从实例开始

    在<通过扩展让ASP.NET Web API支持W3C的CORS规范>中我们通过自定义的HttpMessageHandler为ASP.NET Web API赋予了跨域资源共享的能力,具体来 ...

  4. xamarin UWP证书问题汇总

    打算开发一个软件使用rsa加密的东西,所以有用到数字证书这块,最近遇到些问题, 问题一:使用如下代码添加数字证书后,在证书管理器的当前用户和本地计算机下都找不到这张证书. using (X509Sto ...

  5. java中集合类中Collection接口中的Map接口的常用方法熟悉

    1:Map接口提供了将键映射到值的对象.一个映射不能包含重复的键:每个键最多只能映射到一个值.Map接口中同样提供了集合的常用方法. 2:由于Map集合中的元素是通过key,value,进行存储的,要 ...

  6. 【转】SQL删除重复数据方法,留着备用

    感谢孙潇楠前辈的总结,地址http://www.cnblogs.com/sunxiaonan/archive/2009/11/24/1609439.html 例如: id           name ...

  7. 手把手教你用nodejs+SQL Server2012做增删改查

    1.开发工具WebStorm 10.0.4 2.打开WebStorm 10.0.4新建项目:

  8. 前端学PHP之错误处理

    × 目录 [1]错误报告 [2]错误级别 [3]错误处理[4]自定义错误[5]错误日志[6]异常处理[7]自定义异常 前面的话 错误处理对于程序开发至关重要,不能提前预测到可能发生的错误,不能提前采取 ...

  9. AngularJS之代码风格36条建议【一】(九)

    前言 其实在新学一门知识时,我们应该注意下怎么书写代码更加规范,从开始就注意养成一个良好的习惯无论是对于bug的查找还是走人后别人熟悉代码都是非常好的,利人利己的事情何乐而不为呢,关于AngularJ ...

  10. Android启动icon切图大小

    我们在给app切图的时候不知道告诉ui启动图标切多大,其实你新建一个android项目就知道应该切多大了.新建一个项目会产生几种大小的启动图标. 我把各个文件夹下的ic_launcher.png文件都 ...