前台代码:

<div id="firstpane" class="menu_list">
                <asp:Repeater ID="rep1" runat="server" onitemdatabound="rep1_ItemDataBound">
                    <ItemTemplate>
                        <p class="menu_head" id="p<%# Eval("p_typeid")%>"><%#Eval("type_name") %></p>
                        <div class="menu_body" id="div<%# Eval("p_typeid")%>">
                           
                            <asp:Repeater ID="rep2" runat="server">
                                <ItemTemplate>
                                    <a id="a<%# Eval("p_typeid")%>" href="media.aspx?types=<%# Eval("p_typeid")%>&ptypeid=<%# Eval("p_typepid") %>">
                                        <%# Eval("type_name")%></a>
                                </ItemTemplate>
                            </asp:Repeater>
                              
                        </div>
                    </ItemTemplate>
                </asp:Repeater>
            </div>

后台代码:

protected void rep1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate(该模板定义如何显示控件中的交替项),FooterTemplate(脚模板),

//HeaderTemplate(头模板),ItemTemplate(项模板),SeparatorTemplate(分割模板,元素能够用于描述每个记录之间的分隔符))

if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            if (e.Item.FindControl("rep2") != null)
            {
                DataRowView dv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项

string pid = dv.Row["p_typeid"].ToString();//获取填充子类的id

Repeater rp = (Repeater)e.Item.FindControl("rep2");//找到里层的repeater对象

rp.DataSource = product.getP_typeById(Convert.ToInt32(pid), OleDbHelp.ConnCn);
                rp.DataBind();
            }
        }
    }

关于Repeater嵌套绑定的问题的更多相关文章

  1. Repeater嵌套绑定Repeater

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

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

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

  3. DataList与Repeater嵌套绑定

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

  4. Repeater嵌套绑定Repeater以及内层调用外层数据

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

  5. Repeater 嵌套,子级Repeater获取 父级Repeater 中的值

    第一种方法,子级Repeater中绑定父级的某个字段: <%# DataBinder.Eval((Container.NamingContainer.NamingContainer as Rep ...

  6. 关于Repeater中绑定的控件不触发ItemCommand事件

    今天遇到 在repeater 中使用一个button,点击button然后跳转另外一个页面. html. <asp:Repeater ID="repeater" runat= ...

  7. DataList嵌套绑定例子

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

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

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

  9. repeater三级嵌套绑定

    <asp:Repeater ID="rpt1" runat="server" onitemdatabound="rpt1_ItemDataBou ...

随机推荐

  1. 跨平台C的IDE

    1.JetBrains的新跨平台C++ IDE,CLion已经开始EAP了,不过这货是收费的 http://confluence.jetbrains.com/display/CLION/Early+A ...

  2. uint8_t / uint16_t / uint32_t /uint64_t 是什么数据类型 - 大总结,看完全明白了

    转自:http://blog.csdn.net/kiddy19850221/article/details/6655066 uint8_t / uint16_t / uint32_t /uint64_ ...

  3. dwz的form表单中url的变量替换

    form表单中action的地址格式 “__URL__/edit/{xxx}”,大括号内的 “xxx” 就是变量名,主要功能是结合table组件一起使用. 下图中的删除.编辑.修改密码都是用了url变 ...

  4. matlab练习程序(Sepia Tone滤镜)

    我手机上有一个软件实现了很多图像滤镜,挺有意思,我打算都尝试一下. 这个滤镜主要是实现老照片效果. 代码很短,我就不详细介绍了. 原图: 处理后效果: matlab代码如下: clear all;cl ...

  5. wpf textblock 会覆盖 button里面字体样式的解决方法 还有button的style覆盖。。datepicker里面的按钮的style

    .(button使用contont写的时候) 当.button使用 <button.content><textBlock/></button.content>依然会 ...

  6. Android回调接口的写法

    方法一: 定义一个接口,里面写想要对外提供的方法,在逻辑层方法的参数里传递进去,让在需要的时候调接口里的方法. 实例一: public class SmsUtils { public interfac ...

  7. AndroidTips:selector的disable状态为什么无效?

    正确的姿势: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android=& ...

  8. blade用法

    一.blade条件判断,foreach循环写法 @if(isset($fileInfo) && !empty($fileInfo)) @foreach($fileInfo as $k) ...

  9. MVC 异常处理机制

    方法一 :web.config配置文件的 system.web 接点下添加,若为On则不会将异常信息反馈到用户,而是友好的跳转到error.htm <customErrors mode=&quo ...

  10. NHibernate中多表(对象)间的查询

    一个比较简单的查询代码如下:   IList userList=session.Find (" from testMSSql.student as student where student ...