前台Html代码

<asp:Repeater runat="server" ID="rpList" OnItemDataBound="rpList_ItemDataBound">
<ItemTemplate>
<div class="catItem">
<h2>
<%#Eval("DataValue")%> </h2>
<div class="catType">
<asp:Repeater runat="server" ID="rpListSub">
<ItemTemplate>
<a href="catgory2.aspx?id=<%#Eval("Id")%>"><%#Eval("Name")%></a>
</ItemTemplate>
</asp:Repeater>
</div>
<a href="#" class="cat-more"></a>
</div>
</ItemTemplate>
</asp:Repeater>

后台CS代码:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitData();
}
}
public void InitData()
{
DataTable dt = SysData.GetExpertiseCategoryWeb();//web项目大类
this.rpList.DataSource = dt;
this.rpList.DataBind();
}
protected void rpList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("rpListSub") as Repeater;//找到里层的repeater对象
DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项
int category = Convert.ToInt32(rowv["DataKey"]);//获取填充子类的id
rep.DataSource = SysData.GetExpertiseLevelDTByCategory(category);
rep.DataBind();
}
}

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

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

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

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

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

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

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

  4. DataList与Repeater嵌套绑定

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

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

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

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

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

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

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

  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. jquery控制文字内容溢出用点点点(…)省略号表示

    jQuery限制字符字数的方法 $(function(){ //限制字符个数 $(“.text”).each(function(){ var maxwidth=23; if($(this).text( ...

  2. [LintCode] Add Binary 二进制数相加

    Given two binary strings, return their sum (also a binary string). Have you met this question in a r ...

  3. JAVA 线程同步异步简单实例

    package test; public class testThread { public static void main(String[] args) { Example example = n ...

  4. ASP.NET发布后,功能不响应

    题记:稀奇古怪的错误,往往是由低级脑残错误产生的 ASP.NET网站,本地调试一切正常.部署到服务器后,结果登陆按钮就卡住了,点击就是没反应. 浏览器显示Internal Server Error 5 ...

  5. jQuery cdn使用介绍

    如果您不希望下载并存放jQuery,那么也可以通过 CDN(内容分发网络)引用它,下面是具体实现,有类似需求的各位可以参考下哈,希望对你有所帮助   如果您不希望下载并存放 jQuery,那么也可以通 ...

  6. 前端相关js

    1. mailchimp.js: 通过电子邮件订阅 RSS 的在线工具 2. ga.js:google推出的用来统计网站信息的一个java脚本.可以在GoogleAnalytics获得网站的统计和追踪 ...

  7. 【HDU4630 No Pain No Game】 dp思想+线段树的离线操作

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4630 题意:给你n个数据范围在[1,n]中的数,m个操作,每个操作一个询问[L,R],让你求区间[L, ...

  8. PNG格式的图像文件,创建的图像的MIME类型的头部

    在安装完这三个组件后,还需要重新配置一次PHP,这也是你对采用DSO方式安装PHP感到庆幸的地方之一.运行make clean,然后在当前的配置中添加下面的内容: --with-gd=[/path/t ...

  9. iOS9 HTTP传输安全

    1.在Info.plist中添加 NSAppTransportSecurity 类型  Dictionary 2.在 NSAppTransportSecurity 下添加 NSAllowsArbitr ...

  10. BizTalk2010动手实验(二)第一个BizTalk应用

    1 课程简介 通过本课程了解BizTalk 的消息机制,发布与订阅机制 2 准备工作 3 操作步骤 3.1 创建BizTalk应用程序 1. 新建应用程序 2. 输入应用程序名称 3.2 创建与配置接 ...