Repeater嵌套绑定Repeater
前台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的更多相关文章
- 转:Repeater嵌套绑定Repeater以及内层调用外层数据
<table border=" style="margin-bottom: 5px" width="100%"> <asp:Repe ...
- Repeater嵌套绑定Repeater以及内层调用外层数据
aspx: <table border=" style="margin-bottom: 5px" width="100%"> <as ...
- 关于Repeater嵌套绑定的问题
前台代码: <div id="firstpane" class="menu_list"> <asp:Repeat ...
- DataList与Repeater嵌套绑定
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs&quo ...
- Repeater 嵌套,子级Repeater获取 父级Repeater 中的值
第一种方法,子级Repeater中绑定父级的某个字段: <%# DataBinder.Eval((Container.NamingContainer.NamingContainer as Rep ...
- Repeater嵌套Repeater并取得嵌套Repeater里面的控件
前台代码: <asp:Repeater ID="RepeaterScene" runat="server" OnItemDataBound=&quo ...
- asp.net:repeater嵌套(常用于新闻等在首页归类显示)
using System;using System.Configuration;using System.Collections.Generic;using System.Linq;using Sys ...
- 关于Repeater中绑定的控件不触发ItemCommand事件
今天遇到 在repeater 中使用一个button,点击button然后跳转另外一个页面. html. <asp:Repeater ID="repeater" runat= ...
- 多个不同的表合并到一个datatable中,repeater在绑定datatable
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI ...
随机推荐
- HttpWebRequest Post callback
public void GetValueFromRequest(string postData) { var request = (HttpWebRequest) WebRequest.CreateH ...
- [LintCode] Count and Say 计数和读法
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221 ...
- Eclipse上的项目分享到GitHub
1. 右击项目:team --> Share Project 2. 在弹出的选择框中选择 Git ,点击Next 3. Configure Git Repository 按照下图选择,点击Fin ...
- Thinkphp框架感悟(二)
这次主要分析一下I方法 /** * 获取输入参数 支持过滤和默认值 * 使用方法: * <code> * I('id',0); 获取id参数 自动判断get或者post * I('post ...
- HDU1176
免费馅饼 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- Winform程序以Icon的形式显示在任务栏右下角
Form最小化是指整个Form都缩小到任务栏上,但是是以Form的标题栏形式显示的, 若是想让Form以Icon的形式显示在任务栏右下角,则需要给Form添加一个NotifyIcon控件, 在使窗体最 ...
- liunx系统计划任务管理(at/crond调度)
一.at命令 at命令格式at HH:MM YYYY-MM-DD 其中 HH(小时):MM(分钟) YYYY(年)-MM(月份)-DD(日) 启动atd进程 /etc/init.d/atd start ...
- bootstrap-combined.min.css
/*! * Bootstrap v2.2.2 * * Copyright 2012 Twitter, Inc * Licensed under the Apache License v2.0 * ht ...
- cocos2d-x-3.1.1 创建项目
cocos new 项目名 -p 包名 -l 语言 -d 路径 cmd 输入以下命令 cocos new HelloLua -p com.wcc.hellolua -l lua -d E:\coc ...
- MVC概念性的内容
MVC: 是一个缩写(model + view + control), Model:是一些类文件, 功能:负责增删改查, 负责跟数据库打交道 (把数据存入到数据库: 从数据库把数据读 ...