repeater嵌套c#中Repeater怎么嵌套Repeater?

repeater嵌套  时间:2021-06-13  阅读:()

如何进行Repeater嵌套Repeater

假设存在“大商品”、“小商品”和“货物”两张表,小商品的BID是大商品的外键;货物的GID又是小商品的外键。

那么:

<asp:Repeater id="repBigGoods" DataKeys="xxx"....>

<ItemTemplate>

<%#Eval("BigCategoryName")%>

<asp:Repeater id="repSmallgoods" ... DataSourceId="dsSmallGoods" DataKeys="xxx">

<ItemTemplate> <%#Eval("SmallCategoryName")%>

<asp:Repeater id="repGoods" ...>

<ItemTemplate> <%#Eval("GoodsName")%> </ItemTemplate> </asp:Repeater>

<asp:SqlDataSource id="dsGoods" .... SelectCommand="select GoodsName from goods where gid=@gid"....> <SelectParameter> <asp:Parameter Name="gid" Type="Int32"..../> </SelectParameter> </ItemTemplate>

</asp:Repeater>

<asp:SqlDataSource id="dsSmallGoods" .... SelectCommand="select SmallCategoryName from smalllcategory where bid=@bid"....> <SelectParameter> <asp:Parameter Name="bid" Type="Int32"..../> </SelectParameter>

<ItemTemplate>

</asp:Repeater>

然后:

private void repBigGoods_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if( (item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem) ) { Repeater repsmallgoods = (Repeater) item.FindControl("repSmallgoods"); SqlDataSource dsSmallGoods = (SqlDataSource)repsmallgoods.FindControl("dsSmallGoods")as SqlDataSource; dsSmallGoods.SelectParameters["bid"].DefaultValue = (e.Item As DataRowView).Row["Primary Column Name"].ToString(); } }

private void repSmallgoods_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if( (item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem) ) { Repeater repGoods = (Repeater) repsmallgoods.FindControl("repGoods"); SqlDataSource dsGoods = (SqlDataSource)repsmallgoods.FindControl("dsgoods")as SqlDataSource; dsGoods.SelectParameters["gid"].DefaultValue = (e.Item As DataRowView).Row["Primary Column Name"].ToString(); } }

具体可以参考这里(双层嵌套):

/KB//AspNetNestedRepeaters.aspx

现在有两个repeater控件,分别是repeater1和repeater2,repeater2是嵌套在repeater1的。

获得当前repeater2的ID,然后遍历repeater1中的每一行,如果id一样,那就是哪行了。

这是我想到的最简单的办法,你试试。

也许还能利用datakeys。

c#中Repeater怎么嵌套Repeater?

给你个例子: Repeater菜单导航

新加坡云服务器 1核2Gg 46元/月 香港云服务器 1核2G 74元/月 LightNode

LightNode是一家成立于2002年,总部位于香港的VPS服务商。提供基于KVM虚拟化技术.支持CentOS、Ubuntu或者Windows等操作系统。公司名:厦门靠谱云股份有限公司官方网站:https://www.lightnode.com拥有高质量香港CN2 GIA与东南亚节点(河内、曼谷、迪拜等)。最低月付7.71美金,按时付费,可随时取消。灵活满足开发建站、游戏应用、外贸电商等需求。首...

Pia云服务香港月20元游戏提供香港CN2云服务器

Pia云商家在前面有介绍过一次,根据市面上的信息是2018的开办的国人商家,原名叫哔哔云,目前整合到了魔方云平台。这个云服务商家主要销售云服务器VPS主机业务和服务,云服务器采用KVM虚拟架构 。目前涉及的机房有美国洛杉矶、中国香港和深圳地区。洛杉矶为crea机房,三网回程CN2 GIA,自带20G防御。中国香港机房的线路也是CN2直连大陆,比较适合建站或者有游戏业务需求的用户群。在这篇文章中,简...

pacificrack7月美国便宜支持win VPS,$19.99/年,2G内存/1核/50gSSD/1T流量

pacificrack发布了7月最新vps优惠,新款促销便宜vps采用的是魔方管理,也就是PR-M系列。提一下有意思的是这次支持Windows server 2003、2008R2、2012R2、2016、2019、Windows 7、Windows 10,当然啦,常规Linux系统是必不可少的!1Gbps带宽、KVM虚拟、纯SSD raid10、自家QN机房洛杉矶数据中心...支持PayPal、...

repeater嵌套为你推荐
wazeMWC是什么?视频压缩算法视频压缩方式eagleeye《鹰眼》的男主角是谁?12种颜色12种颜色都是代表什么模式识别算法算法是编程么?考研学模式识别方向,编程多么?assemblyinfo什么是GAC印度尼西亚国家代码谁知道世界各国的国家电话代码?腾讯技术腾讯简介----什么是生态系统生态系统的结构是什么微软操作系统下载怎么下载官方win10 64位镜像系统
出租服务器 香港vps 免费申请网站域名 泛域名绑定 linode日本 优key 创宇云 国内php空间 嘟牛 湖南服务器托管 圣诞促销 什么是刀片服务器 世界测速 什么是服务器托管 php空间购买 微软服务器操作系统 paypal注册教程 卡巴斯基免费试用版 国外在线代理服务器 新加坡空间 更多