Repeater 两层嵌套

ContractedBlock.gif ExpandedBlockStart.gif View Code
 
   
1 <% @ Page Language = " C# " AutoEventWireup = " true " CodeBehind = " list.aspx.cs " Inherits = " Sigil.OutCall.list " %>
2
3 < asp:repeater id = " MainRepeater " runat = " server " onitemdatabound = " MainRepeater_ItemDataBound " >
4 < ItemTemplate >
5 < div class = " Cont " id = " ISL_Cont " >
6 < div class = " ScrCont " >
7 < div id = " List1 " >
8 <!-- 图片列表 begin -->
9 < div class = " pic " > < asp:repeater id = " ImgRepeater " runat = " server " >
10 < ItemTemplate >
11
12 < a href = " <%# Eval( " url " )%> " id = " shot<%# Eval( " productid " )%> " >< img src = " <%# Eval( " filepath " )%> " /></ a >
13
14 <!-- 图片列表 end -->
15 </ ItemTemplate >
16 </ asp:repeater ></ div >
17 </ div >
18 < div id = " List2 " >
19 </ div >
20 </ div >
21 </ div >
22 </ ItemTemplate >
23 </ asp:repeater >

ContractedBlock.gif ExpandedBlockStart.gif Cs Code
 
   
1 using System;
2 using System.Web;
3 using System.Web.UI;
4 using System.Web.UI.WebControls;
5
6 using Sigil.Common;
7 using SigilSoft.Data.SqlClient;
8 using System.Data;
9
10 namespace Sigil.OutCall
11 {
12 public partial class list : System.Web.UI.Page
13 {
14 private Gladiator g = new Gladiator();
15
16 protected void Page_Load( object sender, EventArgs e)
17 {
18 if ( ! IsPostBack)
19 {
20 bindlist();
21 }
22
23 }
24 // 绑定产品
25 private void bindlist()
26 {
27 string sql = @" select p.productid,p.productname,filepath,p.url from product p INNER JOIN attachments a on p.productid = a.itemid where productstate=4 group by p.productid order by p.productid " ;
28
29 MainRepeater.DataSource = g.GetDataTable(sql, SqlStringFrom.Program);
30 MainRepeater.DataBind();
31 }
32 // 绑定图片列表
33 protected void MainRepeater_ItemDataBound( object sender, RepeaterItemEventArgs e)
34 {
35 // 定位里面的Repeater
36 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
37 {
38
39 Repeater imgRepeater = (Repeater)e.Item.FindControl( " ImgRepeater " );
40 // 获取外面Reperter的值
41 DataRowView drv = (DataRowView)e.Item.DataItem;
42 int productid = Convert.ToInt32(drv[ " productid " ]);
43 string sql = @" select p.productid,p.productname,filepath,p.url from product p , attachments a where p.productid = a.itemid and productstate=4 and p.productid= " + productid + "" ;
44 imgRepeater.DataSource = g.GetDataTable(sql, SqlStringFrom.Program);
45 imgRepeater.DataBind();
46 }
47 }
48 }
49 }

转载于:https://www.cnblogs.com/regin/archive/2011/03/24/1994059.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值