转:Repeater嵌套绑定Repeater以及内层调用外层数据
<table border="" cellpadding="" cellspacing="" style="margin-bottom: 5px" width="100%">
<asp:Repeater runat="server" ID="rptypelist" OnItemDataBound="rptypelist_ItemDataBound">
<ItemTemplate>
<tr>
<td class="fb">
<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以及内层调用外层数据的更多相关文章
- Repeater嵌套绑定Repeater以及内层调用外层数据
aspx: <table border=" style="margin-bottom: 5px" width="100%"> <as ...
- Repeater嵌套绑定Repeater
前台Html代码 <asp:Repeater runat="server" ID="rpList" OnItemDataBound="rpLis ...
- 关于Repeater嵌套绑定的问题
前台代码: <div id="firstpane" class="menu_list"> <asp:Repeat ...
- DataList与Repeater嵌套绑定
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs&quo ...
- asp.net:repeater嵌套(常用于新闻等在首页归类显示)
using System;using System.Configuration;using System.Collections.Generic;using System.Linq;using Sys ...
- Repeater 嵌套,子级Repeater获取 父级Repeater 中的值
第一种方法,子级Repeater中绑定父级的某个字段: <%# DataBinder.Eval((Container.NamingContainer.NamingContainer as Rep ...
- Repeater嵌套Repeater并取得嵌套Repeater里面的控件
前台代码: <asp:Repeater ID="RepeaterScene" runat="server" OnItemDataBound=&quo ...
- 关于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 ...
随机推荐
- CSS样式设置记录
在不懂php和wordpress的情况下,需要按照样式内容用php+wordpress+mysql做个网站,网页上有许多样式需要设置,包括颜色字体等要跟要求一致,记录下今天的结果. <div i ...
- 数据库索引<二> 如何创建索引
前面一篇说法了索引结构,和几种索引在数据表上的结构,了解了索引可以为查询服务,这篇说一说如何创建索引. >平时可能的创建方式 这个系统中要用到A字段,B字段,C字段做为查询的条件,联接的条件较多 ...
- TreeList用法(1)
本人按照网上搜的一些小用法整理的: 如果要出现左边的效果,代码如下: public DataTable CreateDataTable() { DataTable ...
- java入门第三步之数据库连接【转】
数据库连接可以说是学习web最基础的部分,也是非常重要的一部分,今天我们就来介绍下数据库的连接为下面学习真正的web打下基础 java中连接数据库一般有两种方式: 1.ODBC——Open Datab ...
- 关于Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)的问题
找不到mysql socket的问题,我最近碰到了好多次重装系统以前,我的mysql,apache,php都是自己编译安装的,当时并没有碰到这些问题,重装系统以后,我的mysql是通过yum安装的,a ...
- [转载]Matrix类的使用
2013-12-18 11:31:00 转载自: http://www.cnblogs.com/mmy0925/archive/2013/01/22/2871009.html 在Android中,对图 ...
- numpy 总结
1.array.sum() from numpy import * import operator group = array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]]) ...
- C#根据当前日期获取星期和阴历日期
private string GetWeek(int dayOfWeek) { string returnWeek = ""; switch (dayOfWeek) { case ...
- c# 多线程创建 ---简单
Thread t = new Thread(new ParameterizedThreadStart(UploadCard)); t.IsBackground = false;//后台线程 前台线程 ...
- 创建和运行shell脚本程序
转载请标明http://www.cnblogs.com/winifred-tang94/ 要创建一个shell脚本程序,首先新建一个文本文件,然后在这个文本文件中按照shell编程规则输入shell命 ...