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

萤光云(20元/月),香港CN2国庆特惠

可以看到这次国庆萤光云搞了一个不错的折扣,香港CN2产品6.5折促销,还送50的国庆红包。萤光云是2002年创立的商家,本次国庆活动主推的是香港CN2优化的机器,其另外还有国内BGP和高防服务器。本次活动力度较大,CN2优化套餐低至20/月(需买三个月,用上折扣+代金券组合),有需求的可以看看。官方网站:https://www.lightnode.cn/地区CPU内存SSDIP带宽/流量价格备注购...

Digital-vm80美元,1-10Gbps带宽日本/新加坡独立服务器

Digital-vm是一家成立于2019年的国外主机商,商家提供VPS和独立服务器租用业务,其中VPS基于KVM架构,提供1-10Gbps带宽,数据中心可选包括美国洛杉矶、日本、新加坡、挪威、西班牙、丹麦、荷兰、英国等8个地区机房;除了VPS主机外,商家还提供日本、新加坡独立服务器,同样可选1-10Gbps带宽,最低每月仅80美元起。下面列出两款独立服务器配置信息。配置一 $80/月CPU:E3-...

快云科技,免云服务器75折优惠服务器快云21元/月

近日快云科技发布了最新的夏季优惠促销活动,主要针对旗下的香港CN2 GIA系列的VPS云服务器产品推送的最新的75折优惠码,国内回程三网CN2 GIA,平均延迟50ms以下,硬件配置方面采用E5 2696v2、E5 2696V4 铂金Platinum等,基于KVM虚拟架构,采用SSD硬盘存储,RAID10阵列保障数据安全,有需要香港免备案CN2服务器的朋友可以关注一下。快云科技怎么样?快云科技好不...

repeater嵌套为你推荐
iso20000认证什么是ISO20000-IT服务管理体系知识分享平台知识付费平台有哪些?自定义表情手机qq添加的自定义表情怎么分组什么是生态系统生态系统的结构是什么微信智能机器人微信群机器人是怎么实现的网站建立需要多少钱创立网站要多少钱移动硬盘文件或目录损坏且无法读取双击移动硬盘提示文件或目录损坏且无法读取怎么回事?收费视频怎么制作收费视频人脸识别解锁iphone人脸识别解锁点心os点心 OS 用户界面(UI)的设计理念是什么?
香港vps 金万维动态域名 cybermonday xfce debian源 轻量 免费网站申请 智能骨干网 免费防火墙 阿里校园 太原网通测速平台 息壤代理 太原联通测速 国外在线代理服务器 广州虚拟主机 葫芦机 移动王卡 脚本大全 酷锐 美国主机侦探 更多