日期:2014-05-18  浏览次数:20575 次

Repeater 怎么循环显示图片?
前台代码:
<asp:Repeater ID="imagesRepeater" runat="server" 
  DataSource='<%# Eval("imageList") %>' DataSourceID="ObjectDataSource1">
  <ItemTemplate>
  <%#Container.ItemIndex != 0 ? (Container.ItemIndex % 3 == 0 ? "</ul><ul>" : "") : ""%>
  <img src="<%# Eval("Url") %>" />
  </ItemTemplate>
  </asp:Repeater>
url是imagesList=里的图片地址元素
后台:
protected void Page_Load(object sender, EventArgs e)
  {
  GetImagesList();
  }

  protected void GetImagesList()
  {
  List<Images> imagesList=B_Images.GetImagesList();
  List<string> l = new List<string>();
  int i=0;
  foreach (Images image in imagesList)
  {
   
  if (image.P_id != 16)
  {
  imagesList.RemoveAt(i);
  }
  i++;
  }
  this.imagesRepeater.DataSource = imagesList;
  this.imagesRepeater.DataBind();
  }

------解决方案--------------------
两种绑定方式好像乱套了
this.imagesRepeater.DataSource = imagesList;
this.imagesRepeater.DataBind();
去掉
DataSource='<%# Eval("imageList") %>' DataSourceID="ObjectDataSource1"