前台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. windows一些快捷键

    1.Win + __ 1)Win + L 锁屏 2)Win + E 资源管理器(就是打开硬盘) 3)Win + D 回到桌面 4)Win + Tab 3D方式切换程序窗口 5)Win + R 运行命令 ...

  2. 广播变量、累加器、collect

    广播变量.累加器.collect spark集群由两类集群构成:一个驱动程序,多个执行程序. 1.广播变量 broadcast 广播变量为只读变量,它由运行sparkContext的驱动程序创建后发送 ...

  3. 在XP下安装PHP

    最近,有许多朋友问我在WindowsXp下PHP的安装过程,正好最近我在自己的机器上成功的以模块化的方式安装了PHP4.23.既然这么多朋友需要,我就以最常见的IIS和Apache服务器为例,把PHP ...

  4. Func<T, TResult> Delegate

    public delegate TResult Func<in T, out TResult>( T arg ) http://msdn.microsoft.com/en-us/libra ...

  5. 采用DOM进行表格的修改操作

    2015-08-31 <html> <head> <title>采用DOM进行表格的修改操作</title> <script language=& ...

  6. 远程访问mysql

    转载:http://www.codesky.net/article/201108/106005.html 数据库不允许从远程访问怎么办?本文提供了三种解决方法: 1.改表法.可能是你的帐号不允许从远程 ...

  7. Spring 配置文件详解 (以2.5为例)

    转载自:http://blog.csdn.net/zzjjiandan/article/details/22922847          Spring配置文件是用于指导Spring工厂进行Bean生 ...

  8. 如何设置div的宽度为100%-xx px?

    如何设置div的宽度为100%-xx px? 参见如下帖子:http://stackoverflow.com/questions/15183069/div-width-100-10px-relativ ...

  9. js中获取键盘事件【转】

    <script type="text/javascript" language=JavaScript charset="UTF-8"> 2 docu ...

  10. Codeforces Beta Round #78 Div. 1 A

    题目链接:http://codeforces.com/contest/98/problem/A 题意大意:给你6种颜色,这6种颜色可能相同也可能不同,把这几种颜色全涂在一个正方体表面,问有多少种涂法( ...