aspx:

  1. <table border="" cellpadding="" cellspacing="" style="margin-bottom: 5px" width="100%">
  2. <asp:Repeater runat="server" ID="rptypelist" OnItemDataBound="rptypelist_ItemDataBound">
  3. <ItemTemplate>
  4. <tr>
  5. <td class="fb">
  6. &nbsp;&nbsp;<a href="Lists.aspx?Qtid=<%#Eval("qtid") %>"><%#Eval("qtypename") %></a> <span id="askCount_15"
  7. class="date2">[<%#Eval("typecount")%>]</span>
  8. </td>
  9. </tr>
  10. <tr>
  11. <td>
  12. <div id="askTop2_15" class="ask_list">
  13. <asp:Repeater runat="server" ID="rpquestionlist">
  14. <ItemTemplate>
  15. <a href="Question.aspx?qid=<%#Eval("liftquestionid")%>">
  16. <%#Eval("questiontitle")%></a><br />
  17.  
  18. 父级数据:<%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "qtid")%>
  19. 父级序号:<%# ((RepeaterItem)Container.Parent.Parent).ItemIndex %>
  20.  
  21. </ItemTemplate>
  22. </asp:Repeater>
  23. </div>
  24. </td>
  25. </tr>
  26. </ItemTemplate>
  27. </asp:Repeater>
  28. </table>

CS

  1. private void Repeater1Bind()
  2. {//GetQuestionTypeAndCount() 返回一个datatable
  3. this.rptypelist.DataSource = LiftQuestionCtr.GetQuestionTypeAndCount();
  4. this.rptypelist.DataBind();
  5. }
  6. protected void rptypelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
  7. {
  8.  
  9. //判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate,
  10.  
  11. //HeaderTemplate,,ItemTemplate,SeparatorTemplate)
  12. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
  13. {
  14. Repeater rep = e.Item.FindControl("rpquestionlist") as Repeater;//找到里层的repeater对象
  15. DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项
  16. int typeid = Convert.ToInt32(rowv["qtid"]); //获取填充子类的id
  17. rep.DataSource = LiftQuestionCtr.GetSomeQuestionsByTypeid(typeid, );
  18. rep.DataBind();
  19. }
  20. }

Repeater嵌套绑定Repeater以及内层调用外层数据的更多相关文章

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

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

  2. Repeater嵌套绑定Repeater

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

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

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

  4. DataList与Repeater嵌套绑定

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

  5. asp.net:repeater嵌套(常用于新闻等在首页归类显示)

    using System;using System.Configuration;using System.Collections.Generic;using System.Linq;using Sys ...

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

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

  7. Repeater嵌套Repeater并取得嵌套Repeater里面的控件

    前台代码:    <asp:Repeater ID="RepeaterScene" runat="server" OnItemDataBound=&quo ...

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

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

  9. 多个不同的表合并到一个datatable中,repeater在绑定datatable

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI ...

随机推荐

  1. TCP三次握手建立关系

    三次握手(three times handshake:three-way handshake)所谓的“三次握手”即对每次发送的数据量是怎样跟踪进行协商使数据段的 发送和接收同步,根据所接收到的数据量而 ...

  2. C# Http访问帮助类,支持get post请求文件下载 [

    using System; using System.Collections.Generic; using System.Collections.Specialized; using System.I ...

  3. 浪漫程序员 HTML5爱心表白动画

    我们程序员在追求爱情方面也是非常浪漫的,下面是一位同学利用自己所学的HTML5知识自制的HTML5爱心表白动画,画面非常温馨甜蜜,这样的创意很容易打动女孩,如果你是单身的程序员,也赶紧来制作自己的爱心 ...

  4. SpringBoot和SpringCloud配置

    1.基本配置 #项目名称(访问路径) server.context-path=/manager #端口 server.port=8764 #session过期时间 server.sessionTime ...

  5. List&Map&Set的操作和遍历

    Java的三大集合即:Set.List.Map. Set:代表无序.不可重复的集合,常用的有HashSet(哈希表实现).TreeSet(红黑树实现): List:代表有序.可以重复的集合,比较常用的 ...

  6. WiFidog 广告路由可修改功能更加智能化的几点看法

    海蜘蛛Tomato出了mini版,这个对很多做WiFi营销的朋友来说,是一个福音,因为可以直接从FIR302B,一台30多块钱的路由直接刷成Hi-WiFi,而且界面这么漂亮 相信很多人已经对此界面OE ...

  7. linux中crontab实战篇

    1.先安装crontab,之前的文章有介绍 2.查看 crontab -l 3.编辑 crontab -e 0 7 * * * /application/php/bin/php www.xialan. ...

  8. asp.net mvc maproute定义可变数量的自定义片断变量

    有时候我们定义了如{controller}/{action}/{id}之类的路由规则,但是后面还可能跟上一堆可能会有可能不会有,但是路由规则是一样的,如{controller}/{action}/{i ...

  9. 【Spark】session 代替 SparkConf、SparkContext和SQLContext

    http://www.raincent.com/content-85-7196-1.html

  10. MongoDB的php可视化管理工具

    使用MongoDB命令查看很不方便 于是想把爬来的数据导出来,看爬来的数据是否正确 打开cmd,执行 mongoexport -d test -c blogs --csv -f title,link, ...