嵌套repeater示例分享

山水山水,有山有水才是好风光。夜色越来越浓了,村落啦,树林子啦,坑洼啦,沟渠啦,好象一下子全都掉进了神秘的沉寂里。

前台代码部分:


<asp:repeater runat="server" id="repeater1" OnItemDataBound="function2">

<itemtemplate>

  <asp:repeater runat="server" id="repeater2">

  <itemtemplate>

  </itemtemplate>

  </asp:repeater>

<itemtemplate>

</asp:repeater>

后台代码部分:


private void function1()
{
  repeater1.datasource = datatable;
  repeater1.databind();
}

private void function2(object sender,repeateritemeventargs e)

{

  //判断里层repeater处于外层repeater的哪个位置(alternatingitemtemplate,footertemplate,headertemplate,itemtemplate,separatortemplate)

if(e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem)

{

repeater rpt = e.item.findcotrol("repeater2") as repeater;  //找到里层的repeater对象

datarowview row = (datarowview)e.item.dataitem;      //找到分类repeater关联的数据项

int typeid = convert.toint32(row["id"]);           //获取填充子类的id

rpt.datasource = datatable;

rpt.databind();

}
}

以上就是嵌套repeater示例分享。人生来如风雨,去如微尘。更多关于嵌套repeater示例分享请关注haodaima.com其它相关文章!

标签: repeater