首页 > 代码库 > 项目--Repeater嵌套横向显示

项目--Repeater嵌套横向显示

前台代码:

<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=http://www.mamicode.com/"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;    }