日期:2014-05-17  浏览次数:20629 次

repeater控件套用repeater,套用repeater里的数据显示
C# 代码:
  protected void Page_Load(object sender, EventArgs e)
  {

  if (!IsPostBack)
  {
  FirstRtype();

  if (Request["rtcd"] == null)
  { }
  else
  {
  TwoProject(Request["rtcd"]);
  }

  }

  }
  public void TwoProject(string rtcd)
  {
   
  string str="2";
  IList list = new WebMethod().SelectT_RtypeLike(str, rtcd);
  DataTable dt = DataTableList.ListToDataSet(list).Tables[0];
  Repeater r = form1.FindControl("repeater1") as Repeater;
  Repeater p = r.Items[0].FindControl("repeater2") as Repeater;
  if (p != null)
  {
  p.DataSource = dt;
  p.DataBind();
  }
  }
   

前台代码:

  <script src="jQuery/jquery-1.4.4.min.js" type="text/javascript"></script>
  <script type="text/javascript">
  function show(rtcd) {
  $.ajax({
  type: "GET",
  url: "TreeLiteral.aspx?&rtcd="+rtcd,
  dataType: "Text",
  success: function(msg) {
  }
  });
  }
   
  </script>

<body>
  <form id="form1" runat="server" >
   
  <div>
  <asp:Repeater runat="server" ID="repeater1">
  <ItemTemplate>
  <div>
  <input type="image" src="images/未命名.jpg" id="img<%# Eval("rtcd") %>" onclick="show('<%# Eval("rtcd") %>')" />
  <a href="#"><%# Eval("rtnm") %></a>
  </div>
  <div id="div<%# Eval("rtcd") %>" style="margin-left:20px;height:10px;">
   
  <asp:Repeater runat="server" ID="repeater2" >
  <ItemTemplate>
  <div>
  <img alt="" class="img2" src="images/未命名.jpg" style="display:block" />
  <a href="#"><%# Eval("RTNM") %></a>
  </div>
  </ItemTemplate>
  </asp:Repeater>
  </div>
  </ItemTemplate>
   
  </asp:Repeater>
  </div>
  </form>
</body>



这是用repeater控件来做一个树状结构,当我点击节点的时候,为什么第二层repeater里的数据未显示呀?请各位大侠解析解析。。。。。

------解决方案--------------------
HTML code

<asp:Repeater runat="server" ID="repeater1" OnItemDataBound="repeater1_ItemDataBound">

------解决方案--------------------
绑定写错了呗
<%# Container.Eval(((Re