<table border="" cellpadding="" cellspacing="" style="margin-bottom: 5px" width="100%">
<asp:Repeater runat="server" ID="rptypelist" OnItemDataBound="rptypelist_ItemDataBound">
<ItemTemplate>
<tr>
<td class="fb">
&nbsp;&nbsp;<a href="Lists.aspx?Qtid=<%#Eval("qtid") %>"><%#Eval("qtypename") %></a> <span id="askCount_15"
class="date2">[<%#Eval("typecount")%>]</span>
</td>
</tr>
<tr>
<td>
<div id="askTop2_15" class="ask_list">
<asp:Repeater runat="server" ID="rpquestionlist">
<ItemTemplate>
<a href="Question.aspx?qid=<%#Eval("liftquestionid")%>">
<%#Eval("questiontitle")%></a><br /> 父级数据:<%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "qtid")%>
父级序号:<%# ((RepeaterItem)Container.Parent.Parent).ItemIndex %> </ItemTemplate>
</asp:Repeater>
</div>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
private void Repeater1Bind()
{//GetQuestionTypeAndCount() 返回一个datatable
this.rptypelist.DataSource = LiftQuestionCtr.GetQuestionTypeAndCount();
this.rptypelist.DataBind();
}
protected void rptypelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{ //判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate, //HeaderTemplate,,ItemTemplate,SeparatorTemplate)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("rpquestionlist") as Repeater;//找到里层的repeater对象
DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项
int typeid = Convert.ToInt32(rowv["qtid"]); //获取填充子类的id
rep.DataSource = LiftQuestionCtr.GetSomeQuestionsByTypeid(typeid, );
rep.DataBind();
}
}

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

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

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

  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. c# 中的委托以及匿名方法lambda

    1.委托的定义internal delegate int MyAddFunDe(int a,int b)2.匿名方法1)MyAddFunDe fun = delegate(int a,int b){  ...

  2. WCF练习小程序总结

    1.什么是WCF 严格的说,WCF就是专门用于服务定制.发布与运行以及消息传递和处理的一组专门类的集合,也就是所谓的“类库”.这些类通过一定方式被组织起来,共同协 作,并为开发者提供了一个统一的编程模 ...

  3. BZOJ3933 [CQOI2015]多项式

    $\sum_{k = 0} ^ {n} a_kx^k = \sum_{k = 0} ^ {n} b_k(x - t)^k \Leftrightarrow \sum_{k = 0} ^ {n} a_k( ...

  4. 可伸缩的textview。

    在一些应用中,比如腾讯的应用市场APP应用宝,关于某款应用的介绍文字,如果介绍文字过长,那么不是全部展现出来,而是显示三四行的开始部分(摘要),预知全部的内容,用户点击展开按钮即可查阅全部内容. 这样 ...

  5. adMob iAd整合,随机根据网络状况自动显示。

    最近找整合的代码,找到的都不对,有个大概对的,但要奔溃退出,只要两个单独弄. adMob 下载好sdk,导入进去,iAd的加入iad framework. 使用方法,在viewController v ...

  6. digitalocean

    sudo apt-get install sshifconfigssh 198.211.102.203sudo adduser uernameubuntu装配SSH,支持开启sftp服务 sftp 1 ...

  7. Js中 关于top、clientTop、scrollTop、offsetTop的用法

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  8. c# access插入null值

    c# 插入access数据库 提示错误: Parameter @DeviceLocation has no default value. 参数@DeviceLocation 的有没有默认值. Stri ...

  9. System.Web.HttpRequestBase转HttpWebRequest

    /// <summary> /// Copies all headers and content (except the URL) from an incoming to an outgo ...

  10. HashMap简单理解

    1. hashmap基于哈希表的map接口实现,此实现提供所有可选的映射操作,并允许使用 null 值和 null 键.(除了非同步和允许使用 null 之外,HashMap 类与 Hashtable ...