ASP.NET 中关于递归的问题

chxn220 2010-12-12 12:30:27
protected void ibt_update_type_Click(object sender, EventArgs e)
{
DataTable dt = bs.GetDictionary(" ").Table;
for (int i = 0; i < dt.Rows.Count; i++)
{
string pid = dt.Rows[i]["tp_id"].ToString();
string classid = pid + ",";
classid = GetBindNode(classid, pid);
classid = classid.Substring(0, classid.Length - 1);
bool isbo = be.update_class(classid, pid);
}
}
//绑定子分类
string GetBindNode(string classid, string parentid)
{
DataTable smdt = bs.GetDictionary(" and tp_ParentId= " + parentid).Table;
int it = smdt.Rows.Count;
if (it == 0)
{
return classid;
}
else
{
for (int i = 0; i < smdt.Rows.Count; i++)
{
string csid = smdt.Rows[i]["tp_id"].ToString();
classid += smdt.Rows[i]["tp_id"].ToString() + ",";
GetBindNode(classid, csid);
}
}
return classid;
}
为什么我让it等于O的时候退出这个方法 ,但是为什么他不退出继续执行for循环里面的GetBindNode方法,这样导致classid里面只能追加两个,其它的都追加不上。谢谢各位。。我头疼一天了。。。帮帮忙。。。
...全文
51 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
happy664618843 2010-12-12
  • 打赏
  • 举报
回复
看不懂

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧