62,073
社区成员
发帖
与我相关
我的任务
分享
#region 根据编号获取配收件地址信息
protected string GetAddress(object aid)
{
Category cate = new Category();
CategoryBLL cabll = new CategoryBLL();
string title = "";
if (aid != null)
{
cate = cabll.GetModel(Convert.ToInt32(aid));
title = GetUpAddress(cate.title.ToString(),cate.parentId);
}
return title;
}
#endregion
#region 根据父类编号获取上级地址
protected string GetUpAddress(string name,object parentid)
{
DataSet ds = new DataSet();
CategoryBLL cabll = new CategoryBLL();
Category cate = new Category();
Category cate1 = new Category();
string title = name;
try
{
cate = cabll.GetModelBySql("id=" + Convert.ToInt32(parentid));
if (cate != null && cate.parentId != 0)
{
title = title.Insert(0, cate.title.ToString());
cate1 = cabll.GetModelBySql("id=" + cate.parentId);
if (cate1 != null && cate1.parentId != 0)
{
GetUpAddress(title, cate.parentId);
}
}
}
catch (Exception ex)
{
log.Error(ex.Message);
}
return title;
}
#endregion
<td align="center">
<%# GetAddress(Eval("aid")) %>
</td>
protected string GetUpAddress(string name,object parentid)
{
DataSet ds = new DataSet();
CategoryBLL cabll = new CategoryBLL();
Category cate = new Category();
Category cate1 = new Category();
string title = name;
try
{
cate = cabll.GetModelBySql("id=" + Convert.ToInt32(parentid));
if (cate != null && cate.parentId != 0)
{
title = title.Insert(0, cate.title.ToString());
cate1 = cabll.GetModelBySql("id=" + cate.parentId);
if (cate1 != null && cate1.parentId != 0)
{
title += GetUpAddress(title, cate.parentId);
}
}
}
catch (Exception ex)
{
log.Error(ex.Message);
}
return title;
}