我现在在后台创建的Treeview对象 !数据已经添加好了!但是怎么才能让他在页面上显示呢?
各位大侠帮一下!急!!!!!!!!!!!

解决方案 »

  1.   

    你是返回的什么类型的  拼接的么 <%=方法名%>
    不是的话 你前面不是 有Treeview控件么 直接绑定数据源就Ok了啊
      

  2.   


    返回的一个string类型的
    你拼接好了输出是没有什么问题的
    如果有问题
    请你帖代码
      

  3.   

     //显示商品类型信息
            protected string ShowCategoryInfo()
            {
                #region   商品类型信息详情            DataSet ds = pcbll.GetProCategorys();
                StringBuilder str = new StringBuilder();
                str.Append("<table class=\"table\" cellspacing=\"1\" cellpadding=\"5\" width=\"100%\" border=\"0\">");
                str.Append("<tr ><td height=\"23\" colspan=\"2\">商品类型列表 </td></tr>");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow[] drow = ds.Tables[0].Select("ParentProId=0");
                    for (int i = 0; i < drow.Length; i++)
                    {
                        DataRow[] dr = ds.Tables[0].Select("ParentProId=" + drow[i]["ProCategoryId"]);
                        if (dr.Length > 0)
                        {
                            str.Append("<tr><td class=\"td_bg\" colspan=\"2\"><span id='" + drow[i]["ProCategoryId"] + "'><img id='Pimg" + drow[i]["ProCategoryId"] + "' src=\"Images/+.gif\" alt=\"\" />" + drow[i]["ProCategoryName"] + "</span>&nbsp;&nbsp;<a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','','','1')\" >添加</a>&nbsp;&nbsp;<a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','" + drow[i]["ProCategoryName"] + "','" + drow[i]["ProCategoryOrder"] + "','2')\" >修改</a>&nbsp;&nbsp;<a href=\"javascript:DelProCategory('" + drow[i]["ProCategoryId"] + "')\">删除</a></td></tr>");
                            for (int j = 0; j < dr.Length; j++)
                            {
                                str.Append("<tr id='s" + drow[i]["ProCategoryId"] + "' style='display:none'><td class=\"td_bg\" style=\"padding-left: 20px\"><img src=\"Images/-.gif\" alt=\"\" />" + dr[j]["ProCategoryName"] + "&nbsp;&nbsp;</td><td class=\"td_bg\"><a href=\"javascript:operateview('" + dr[j]["ProCategoryId"] + "','" + dr[j]["ProCategoryName"] + "','" + dr[j]["ProCategoryOrder"] + "','2')\" >修改</a>&nbsp;&nbsp;<a href=\"javascript:DelProCategory('" + dr[j]["ProCategoryId"] + "')\">删除</a></td></tr>");
                            }
                        }
                        else
                        {
                            str.Append("<tr><td class=\"td_bg\" colspan=\"2\"><span id='" + drow[i]["ProCategoryId"] + "'>&nbsp;&nbsp;&nbsp;" + drow[i]["ProCategoryName"] + "</span>&nbsp;&nbsp;<a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','','','1')\" >添加</a>&nbsp;&nbsp;<a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','" + drow[i]["ProCategoryName"] + "','" + drow[i]["ProCategoryOrder"] + "','2')\" >修改</a>&nbsp;&nbsp;<a href=\"javascript:DelProCategory('" + drow[i]["ProCategoryId"] + "')\">删除</a></td></tr>");
                        }
                    }
                }
                str.Append("</table>");
                return str.ToString();            #endregion
            }        //添加,修改商品类型操作
            protected void Operate_Click(object sender, EventArgs e)
            {
                #region  具体操作
                //添加
                string UorI = UpdateOrInsert.Value;
                if (int.Parse(UorI) == 1)
                {
                    string proCategoryName = categoryname.Text.ToString(); //商品类型名字
                    string parentids = parentid.Value.ToString();  //父id
                    int order = Convert.ToInt32(categoruorder.Text.ToString()); //商品类型排序
                    if (pcbll.AddProCategory(proCategoryName, int.Parse(parentids), order) == true)
                    {
                        this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "location='productgroup.aspx'", true);
                    }
                    else
                    {
                        this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('添加失败!')", true);
                    }
                }
                //修改
                if (int.Parse(UorI) == 2)
                {
                    ProCategoryInfo p = new ProCategoryInfo();
                    //父id的id
                    p.ProCategoryId = int.Parse(procategoryid.Value);
                    p.ProCategoryName = categoryname.Text.ToString();
                    p.ProCategoryOrder = Convert.ToInt32(categoruorder.Text.ToString()); //商品类型排序                if (pcbll.UpdateProCategory(p))
                    {
                        this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "location='productgroup.aspx'", true);                }
                    else
                    {
                        this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('修改失败!')", true);
                    }            }
                #endregion
            }
            //删除商品类型
            protected void DelProCategorys()
            {
                if (Request.QueryString["pid"] != null)
                {
                    string pid = Request.QueryString["pid"].ToString();
                    if (pcbll.IsHaveProCategory(int.Parse(pid)) == true)
                    {
                        Response.Write("-1");
                    }
                    else
                    {
                        if (pcbll.DelProCategory(int.Parse(pid)) == true)
                        {
                            Response.Write("1");
                        }
                        else
                        {
                            Response.Write("0");
                        }
                    }
                    Response.End();
                }
            }如果你不会拼接 给你参考
      

  4.   

    这样拼接还会有selectindexchenge事件什么我现在的任务是优化别人写好的代码  逻辑什么的最好别改变!!