public partial class UserControls_ucHomeProductType : SiteUserControlBase
{
    public  ActProductTypeList action;
    public string strProductRootTypeList = string.Empty;
    public string strProductTypeList = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        action = new ActProductTypeList(Context);
    }    public override void DataBind()
    {
        base.DataBind();
        //从数据库将所有类别取出来,下面全部通过linq进行查询
        List<ProductType> listAllType = action.GetProductTypeAllListLinq();
        //绑定根目录
        IList listRoot = listAllType.Where(item => item.CurrentFloor == 1).ToList<ProductType>();        foreach (ProductType rootItem in listRoot)
        {
            //绑定头部根目录
            strProductRootTypeList += " <a href=\"Product/ProductTypeList.aspx?RootID=" + rootItem.ID + "\"><span>" + rootItem.TypeName + "</span></a>";
        }
        /**************************************************************************************/
        //开始绑定子目录列表
        foreach (ProductType rootItem in listRoot)
        {            strProductTypeList += "<ul class='walink'>\n";
            //绑定二级目录(设置绑定个数)
            List<ProductType> listSecond = GetProductTypeChildList(2, rootItem.ID, listAllType);
            int listSecondCount = listSecond.Count;
            for (int isecond = 0; isecond < 8; isecond++)
            {
                if (listSecondCount <= isecond)
                    continue;                if (isecond > listSecondCount || listSecondCount == 0)
                    continue;                ProductType secondItem = listSecond[isecond] as ProductType;                // 
                strProductTypeList += "<a href=\"Product/ProductList.aspx?ProductTypeID=" + secondItem.ID + "\">" + secondItem.TypeName + "</a>\n";                //绑定三级目录,只取前六个,然后根据字数只显示其中一部分
                List<ProductType> listThree = GetProductTypeChildList(3, secondItem.ID, listAllType);
                if (listThree.Count > 0)
                {
                    //记录字数来判断只显示一行
                    int strFontLength = 0;
                    for (int ithree = 0; ithree < listThree.Count; ithree++)
                    {
                        ProductType threeItem = listThree[ithree] as ProductType;                        strFontLength += threeItem.TypeName.Length;                        if (strFontLength > 11)
                        {
                            //为了兼容IE6,将这段话放到前面去了
                            //strProductTypeList += "<div style='display:inline;overflow:hidden;margin-top:0px;margin-right:0px;padding-right:0px'><a href=\"Product/ProductList.aspx?ProductTypeID=" + secondItem.ID + "\">更多</a></div>";
                            break;
                        }                    }                }                //在这里添加弹出层
            }            strProductTypeList += "</ul>\n";
        }        /************************************************************************************/
    }    /// <summary>
    /// 获取产品类别孩子列表
    /// </summary>
    /// <param name="floor">所需要获取的层次,2或3或4</param>
    /// <param name="parentid"></param>
    /// <returns></returns>
    List<ProductType> GetProductTypeChildList(int floor, string parentid, List<ProductType> listAll)
    {
        IEnumerable<ProductType> childList = new List<ProductType>();
        switch (floor)
        {
            case 2:
                childList = listAll.Where(item => item.CurrentFloor == 2).Where(item => item.FloorOneID == parentid);
                break;
            case 3:
                childList = listAll.Where(item => item.CurrentFloor == 3).Where(item => item.FloorTwoID == parentid);
                break;
            default:
                throw new Exception("获取子产品类别参数不对");
        }        if (childList != null)
            return childList.ToList<ProductType>();        return null;
    }
}
以前是这个效果的,我现在想要写一个三级分类和二级分类的字符串,直接 在html里输出这个字符串,不会C#.net,求高手帮我搞下,谢谢了