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

TMThosting:VPS月付55折起,独立服务器9折,西雅图机房,支持支付宝

TMThosting发布了今年黑色星期五的促销活动,即日起到12月6日,VPS主机最低55折起,独立服务器9折起,开设在西雅图机房。这是一家成立于2018年的国外主机商,主要提供VPS和独立服务器租用业务,数据中心包括美国西雅图和达拉斯,其中VPS基于KVM架构,都有提供免费的DDoS保护,支持选择Windows或者Linux操作系统。Budget HDD系列架构CPU内存硬盘流量系统价格单核51...

欧路云(22元/月),美国CERA弹性云服务器!香港弹性云服务器15元/月起;加拿大高防vps仅23元/月起

欧路云怎么样?欧路云主要运行弹性云服务器,可自由定制配置,可选加拿大的480G超高防系列,也可以选择美国(200G高防)系列,也有速度直逼内地的香港CN2系列。所有配置都可以在下单的时候自行根据项目 需求来定制自由升级降级 (降级按天数配置费用 退款回预存款)。2021年7月14日美国 CERA 弹性云服务器 上新 联通CUVIP 线路!8折特惠中!点击进入:欧路云官方网站地址付款方式:PayPa...

ZJI:520元/月香港服务器-2*E5-2630L/32GB/480G SSD/30M带宽/2IP

ZJI发布了一款7月份特别促销独立服务器:香港邦联四型,提供65折优惠码,限量30台(每用户限购1台),优惠后每月520元起。ZJI是原来Wordpress圈知名主机商家:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册等业务。下面列出这款服务器的配置信息。香港邦联四型CPU:2*E5-2...

repeater嵌套为你推荐
qq业务查询怎么查询别人为我开通的QQ业务?Honeypotfeedback 歌词翻译at89s52单片机AT89S52单片机和AT89C51单片机的区别eagleeye电脑进程中出现Eaglesvr这种程序,据说是一种蠕虫病毒。。。怎样杀掉?chrome系统Chrome操作系统是什么样的系统?人肉搜索引擎怎样使用人肉搜索引擎?seo优化技术SEO技术是什么?js后退javascript怎么禁用浏览器后退按钮模式识别算法模式识别的简史assemblyinfo什么是GAC
北京域名注册 好看的桌面背景图片 免费smtp服务器 100m空间 33456 四核服务器 银盘服务 东莞主机托管 浙江服务器 工信部icp备案查询 阿里云邮箱个人版 windowsserver2008 cx域名 apachetomcat 发证机构 symantec 德国代理 回程 海康流媒体服务器 sockscap教程 更多