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菜单导航

Sharktech:无限流量服务器丹佛,洛杉矶,荷兰$49/月起,1Gbps带宽哦!

鲨鱼机房(Sharktech)我们也叫它SK机房,是一家成立于2003年的老牌国外主机商,提供的产品包括独立服务器租用、VPS主机等,自营机房在美国洛杉矶、丹佛、芝加哥和荷兰阿姆斯特丹等,主打高防产品,独立服务器免费提供60Gbps/48Mpps攻击防御。机房提供1-10Gbps带宽不限流量服务器,最低丹佛/荷兰机房每月49美元起,洛杉矶机房最低59美元/月起。下面列出部分促销机型的配置信息。机房...

.asia域名是否适合做个人网站及.asia域名注册和续费成本

今天看到群里的老秦同学在布局自己的网站项目,这个同学还是比较奇怪的,他就喜欢用这些奇怪的域名。比如前几天看到有用.in域名,个人网站他用的.me域名不奇怪,这个还是常见的。今天看到他在做的一个范文网站的域名,居然用的是 .asia 后缀。问到其理由,是有不错好记的前缀。这里简单的搜索到.ASIA域名的新注册价格是有促销的,大约35元首年左右,续费大约是80元左右,这个成本算的话,比COM域名还贵。...

Vultr新用户省钱福利,最新可用优惠码/优惠券更新

如今我们无论线上还是线下选择商品的时候是不是习惯问问是不是有优惠活动,如果有的话会加速购买欲望。同样的,如果我们有准备选择Vultr商家云服务器的时候,也会问问是不是有Vultr优惠码或者优惠券这类。确实,目前Vultr商家有一些时候会有针对新注册用户赠送一定的优惠券活动。那就定期抽点时间在这篇文章中专门整理最新可用Vultr优惠码和商家促销活动。不过需要令我们老用户失望的,至少近五年我们看到Vu...

repeater嵌套为你推荐
GoldenDBGolden Handcuffs是什么意思?performclickC#中 键盘entre执行确定命令的代码是什么qq博客怎么开QQ博客啊!印度尼西亚国家代码国际代码labelforandroid:labelfor是什么意思labelforhtml中label是什么意思啊?单元测试规范求解,单片机程序的单元测试应该怎么做呢?activitygroupActivityGroup子activity之间的切换效果怎么实现收费视频怎么制作收费视频网络备份网络系统备份的主要目的以及网络系统备份体系主要包括哪几方面?
免费申请域名和空间 美国主机论坛 idc资讯 股票老左 刀片式服务器 速度云 什么是服务器托管 吉林铁通 中国电信宽带测速器 超级服务器 联通网站 独享主机 太原联通测速 shuang12 英国伦敦 lamp什么意思 阿里云邮箱登陆 免费网络空间 乐视会员免费领取 alexa世界排名 更多