前台代码:
<style type="text/css"> .list { list-style-type: none; text-align:center; } .list li { float: left; width: 160px; } </style>
<ul class="list"> <asp:Repeater runat="server" ID="rptType"> <ItemTemplate> <li> <h4><%#Eval("HTName")%></h4> <ul> <asp:Repeater runat="server" ID="rptDetail" DataSource=‘<%#GetTypeDetail(Eval("HTID").ToString()) %>‘> <ItemTemplate> <li> <p> <a href="Help.aspx?id=<%#Eval("HIid") %>" style="color:#666666"> <%#Eval("HItitle")%> </a> </p> </li> </ItemTemplate> </asp:Repeater> </ul> </li> </ItemTemplate> </asp:Repeater> </ul>
后台代码:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = DBClass.GetDataTable("select * from TBHelpType where isshow=1 order by sortid"); rptType.DataSource = dt; rptType.DataBind(); } } protected DataTable GetTypeDetail(string strHTID) { DataTable result = null; if (!string.IsNullOrEmpty(strHTID)) { result = DBClass.GetDataTable(string.Format("select * from TBHelpInfo where isshow=1 and HTID = {0} order by sortid",strHTID)); } return result; }
项目--Repeater嵌套横向显示
时间: 2024-10-13 20:27:53