TreeView问题! 我现在在后台创建的Treeview对象 !数据已经添加好了!但是怎么才能让他在页面上显示呢?各位大侠帮一下!急!!!!!!!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你是返回的什么类型的 拼接的么 <%=方法名%>不是的话 你前面不是 有Treeview控件么 直接绑定数据源就Ok了啊 返回的一个string类型的你拼接好了输出是没有什么问题的如果有问题请你帖代码 //显示商品类型信息 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> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','','','1')\" >添加</a> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','" + drow[i]["ProCategoryName"] + "','" + drow[i]["ProCategoryOrder"] + "','2')\" >修改</a> <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"] + " </td><td class=\"td_bg\"><a href=\"javascript:operateview('" + dr[j]["ProCategoryId"] + "','" + dr[j]["ProCategoryName"] + "','" + dr[j]["ProCategoryOrder"] + "','2')\" >修改</a> <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"] + "'> " + drow[i]["ProCategoryName"] + "</span> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','','','1')\" >添加</a> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','" + drow[i]["ProCategoryName"] + "','" + drow[i]["ProCategoryOrder"] + "','2')\" >修改</a> <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(); } }如果你不会拼接 给你参考 这样拼接还会有selectindexchenge事件什么我现在的任务是优化别人写好的代码 逻辑什么的最好别改变!! 项目分层 如何动态的传值 学习ASP.NET GridView中的BoundField,如何把decimal(18,2)型小数点的00去掉,如12.00只显示12 正则表达式取img 标记的 src值,csdn里早期的答复都有bug C#开发ASP.NET时遇到的问题!谢谢大伙! 巨难的问题!xml转word~~~~~~~~~~~~~~~~~~` 如何在客户端中修改服务器控件的值? 怎样在SQL数据库中加入ASP。NET的访问权限? 求word痕迹保留的控件。 求助!添加ajax Toolkit.dll后运行报错!! 急求log4net控件配置
不是的话 你前面不是 有Treeview控件么 直接绑定数据源就Ok了啊
返回的一个string类型的
你拼接好了输出是没有什么问题的
如果有问题
请你帖代码
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> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','','','1')\" >添加</a> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','" + drow[i]["ProCategoryName"] + "','" + drow[i]["ProCategoryOrder"] + "','2')\" >修改</a> <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"] + " </td><td class=\"td_bg\"><a href=\"javascript:operateview('" + dr[j]["ProCategoryId"] + "','" + dr[j]["ProCategoryName"] + "','" + dr[j]["ProCategoryOrder"] + "','2')\" >修改</a> <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"] + "'> " + drow[i]["ProCategoryName"] + "</span> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','','','1')\" >添加</a> <a href=\"javascript:operateview('" + drow[i]["ProCategoryId"] + "','" + drow[i]["ProCategoryName"] + "','" + drow[i]["ProCategoryOrder"] + "','2')\" >修改</a> <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();
}
}如果你不会拼接 给你参考