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

<table border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 5px" width="100%">
    <asp:Repeater runat="server" ID="rptypelist" OnItemDataBound="rptypelist_ItemDataBound">
        <ItemTemplate>
            <tr>
                <td class="fb">
                    &nbsp;&nbsp;<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, 2);
                rep.DataBind();
            }
        }
时间: 2024-10-28 21:24:07

转:Repeater嵌套绑定Repeater以及内层调用外层数据的相关文章

Repeater嵌套绑定Repeater

<asp:Repeater runat="server" ID="rpList" OnItemDataBound="rpList_ItemDataBound"> <ItemTemplate> <div class="catItem"> <h2> <%#Eval("DataValue")%> </h2> <div class=&qu

关于Repeater嵌套绑定的问题

前台代码: <div id="firstpane" class="menu_list">                <asp:Repeater ID="rep1" runat="server" onitemdatabound="rep1_ItemDataBound">                    <ItemTemplate>                 

DataList与Repeater嵌套绑定

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs" Inherits="home" %> <body> <form id="form1" runat="server"> <asp:DataList ID="monitorTypeList"

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

using System;using System.Configuration;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.Htm

Repeater嵌套gridview

前台:<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="Repeater1_ItemDataBound">        <ItemTemplate>           id:<%#Eval("ID")%>           carid:

项目--Repeater嵌套横向显示

前台代码: <style type="text/css"> .list { list-style-type: none; text-align:center; } .list li { float: left; width: 160px; } </style> <ul class="list"> <asp:Repeater runat="server" ID="rptType">

多个不同的表合并到一个datatable中,repeater在绑定datatable

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;namespace LZserverList{    public partial class LZList : System.Web.UI.

使用HBuilder开发移动APP:ajax调用接口数据

既然要做APP,与接口交互式少不了的,除非只是想做一个纯静态的APP.所以html5+的环境准备好后,我最先开始研究的就是如何与接口交互. 使用HBuilder新建示例教程后,里面会有一个ajax(网络请求)的列子,文件目录是examples/ajax.html.看了下这个文件的代 码,它的功能就是点击“提交”按钮后提交参数给接口,然后根据选择的返回数据格式,将一段字符串打印出来.我准备改造下这段代码,改由页面加载时调用列表 接口,并在APP里显示这段列表,毕竟这种情况应该经常会用到. 1.在l

webservice篇:其中关于调用外界数据,读取返回数据

1,通过Android中已存取的数据,返回数据(json格式,object类型数据:strJson) 2,业务需求:通过webservice调用外界暴露的数据并将返回来的json数据序列化,读取存入数据库表:[SQ_Event] TODO: 1,讲解webservice小程序应用 2,json序列化 1,讲解webservice小程序应用 using HMFW.BLL.BaseInfo; using HMFW.BLL.SQJS.ZJWG; using HMFW.BLL.UserRoleManag