zoukankan      html  css  js  c++  java
  • 嵌套repeater

    通过外层repeater的值来进行内层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();

    }

    }

  • 相关阅读:
    C#操作XML配置文件
    Git详细命令
    ng : File C:UsersaronAppDataRoaming pm g.ps1 cannot be loaded because running
    Abstract抽象类 && Interface接口
    Markdown基本使用
    Scrapy基本使用
    request取值相关
    轮询与长轮询
    爬虫
    Flask相关组件及应用
  • 原文地址:https://www.cnblogs.com/lhm814/p/3606053.html
Copyright © 2011-2022 走看看