源码下载地址:http://download.csdn.net/source/906725
Repeater嵌套:
前台
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="rptNesting.aspx.cs" Inherits="nesting_rptNesting" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>Repeater的嵌套用法</title>
- <script type="text/javascript">
- function f(oid){
- var d = document.getElementById(oid);
- if(d.className == "non")
- d.className = "dis";
- else
- d.className = "non";
- }
- </script>
- <style type="text/css">
- .dis{display:block;float:left;}
- .non{display:none;float:left;}
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:Repeater ID="rptParent" runat="server" OnItemDataBound="rptParent_ItemDataBound">
- <ItemTemplate>
- <div>
- <div>
- <%#Eval("typeid_1") %><%#Eval("typename") %>
- <input type="button" value="显示小类" onclick='f(<%#Eval("typeid_1") %>)' />
- </div>
- <div id='<%#Eval("typeid_1") %>' class="non">
- <asp:Repeater ID="rptChild" runat="server">
- <ItemTemplate>
- <div style="background:#369">
- <%#Eval("typeid_2") %><%#Eval("typename") %>