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

Hostodo:$19.99/年KVM-1GB/12GB/4TB/拉斯维加斯

Hostodo发布了几款采用NVMe磁盘的促销套餐,从512MB内存起,最低年付14.99美元,基于KVM架构,开设在拉斯维加斯机房。这是一家成立于2014年的国外VPS主机商,主打低价VPS套餐且年付为主,基于OpenVZ和KVM架构,产品性能一般,数据中心目前在拉斯维加斯和迈阿密,支持使用PayPal或者支付宝等付款方式。下面列出几款NVMe硬盘套餐配置信息。CPU:1core内存:512MB...

raksmart:香港机房服务器实测评数据分享,告诉你raksmart服务器怎么样

raksmart作为一家老牌美国机房总是被很多人问到raksmart香港服务器怎么样、raksmart好不好?其实,这也好理解。香港服务器离大陆最近、理论上是不需要备案的服务器里面速度最快的,被过多关注也就在情理之中了。本着为大家趟雷就是本站的光荣这一理念,拿了一台raksmart的香港独立服务器,简单做个测评,分享下实测的数据,仅供参考!官方网站:https://www.raksmart.com...

提速啦香港独立物理服务器E3 16G 20M 5IP 299元

提速啦(www.tisula.com)是赣州王成璟网络科技有限公司旗下云服务器品牌,目前拥有在籍员工40人左右,社保在籍员工30人+,是正规的国内拥有IDC ICP ISP CDN 云牌照资质商家,2018-2021年连续4年获得CTG机房顶级金牌代理商荣誉 2021年赣州市于都县创业大赛三等奖,2020年于都电子商务示范企业,2021年于都县电子商务融合推广大使。资源优势介绍:Ceranetwo...

repeater嵌套为你推荐
avb医学avb是什么意思股价图简单易懂的股票图外加说明jstz江苏泰州市地税如何申报?数据挖掘项目将来想从事统计分析和数据挖掘,需要哪些技能腾讯技术腾讯简介----assemblyinfocsgo很跟cs有什么区别什么是生态系统生态系统的功能有什么?微软操作系统下载怎样在微软官网下载windows7 64位旗舰版xcelsius谁有水晶易表2008的密钥?xcelsiussap bi是什么
虚拟主机管理系统 香港vps主机 重庆vps租用 鲨鱼机 香港托管 双11抢红包攻略 ubuntu更新源 华为云主机 网通服务器ip 绍兴高防 元旦促销 me空间社区 33456 web服务器安全 爱奇艺会员免费试用 中国电信测速网站 贵州电信 ncp winserver2008r2 防盗链 更多