项目--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="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;
    }

 

posted @ 2014-08-08 10:29  步子521  阅读(261)  评论(0编辑  收藏  举报