前台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获取ul中第一个li的属性

    当加载列表时,默认希望选中第一条.top_menu 为ul的ID 通过 $("#top_menu li:first") 就可以获取到 ul下第一个li标签.然后就可以利用 例如 修 ...

  2. 学习bootstrap心得

    Bootstrap 使用了一些 HTML5 元素和 CSS 属性.为了让这些正常工作,您需要使用 HTML5 文档类型(Doctype). 因此,请在使用 Bootstrap 项目的开头包含下面的代码 ...

  3. find命令详解

    find命令详解   来源: ChinaUnix博客 日期: 2008.07.25 16:04 (共有条评论) 我要评论   [url=http://www.sudu.cn/web/host.php] ...

  4. Android:The connection to adb is down, and a severe error has occured.解决方法一

    在自己机上打安桌虚拟机,竟然提示“The connection to adb is down, and a severe error has occured.please ensure ......” ...

  5. getElementsByClassName的兼容性

    /*----------------------------index.html------------------------------------*/ <!DOCTYPE html> ...

  6. thinkphp3.2设置session的过期时间

    thinkPHP3.2中session的过期时间配置是不能使用的,我们需要修改一下它的配置文件thinkPHP>common>functions.php,找到这一行: if(isset($ ...

  7. Webform购物车(用Session存储,页面传值)

    购物车主要实现的功能: ①在主页面可以将所有商品显示出来,包括价格,库存. ②点击购买可以累加产品,如果是同一种产品,只会累加每种产品的数量. ③查看购物车,可以查看明细,包括所购物品的名称,价格,数 ...

  8. SSH环境 jsp url跳转,带中文参数乱码问题

    URL中编码格式为ISO-8859-1,处理中文只需将编码格式转换ISO-8859-1 方法一: http://xxx.do?ptname='我是中国人' String strPtname = req ...

  9. SQL,LINQ,Lambda语法对照图(转载)

    如果你熟悉SQL语句,当使用LINQ时,会有似曾相识的感觉.但又略有不同.下面是SQL和LINQ,Lambda语法对照图 SQL LINQ Lambda SELECT * FROM HumanReso ...

  10. jetBrains phpstorm/webstorm 编辑器使用诀窍

    下载地址 https://www.jetbrains.com/products.html?fromMenu CTRL + F12 / COMMAND + F12 打开类中的结构 Ctrl + b / ...