如何从数据库表数据生成无序列表?
问题描述:
您好我有一个无序列表<ul><li><ul><li>
如何从数据库表数据生成无序列表?
我做了一个表,以填补无序列表,但如何获取这些数据转化为li
和ul
表由家庭,组织(儿童政策,employeesdetails)等等..我如何填写这些ul
和li
的和li
的孩子的数据从sqlserver2005表? 我不应该使用内置控件像asp.net菜单
foreach (DataRow row in dt.Rows)
{
int currentDepth = Convert.ToInt32(row["Depth"]);
if (lastDepth < currentDepth)
{
output.Append("<ul class=\"dropdown\">");
numUL++ ;
}
else if (lastDepth > currentDepth)
{
output.Append("</li></ul></li>");
numUL-- ;
}
else if (lastDepth > -1)
{
output.Append("</li>");
}
output.AppendFormat("<li class=\"depth-{1}\">{0}", row["ApplicationName"], currentDepth);
lastDepth = currentDepth;
}
for (int i = 1;i <= numUL;i++)
{
output.Append("</li></ul>");
}
Literal1.Text = output.ToString();
我已经基于上面的代码所做的导航栏任何asp.net 我的导航栏看起来像这样
首页|组织|人才招聘|帮助问题
我得到的所有李时珍正确(如部门和用户在组织) 我有一个prolem我如何得到的URL动态地日上述E代码
我的表看起来像这样
ApplicationID ApplicationName ParentKey Depth URL 1 HOME NULL 0 # 2 Organisation NULL 0 # 3 Department 2 1 # 4 User 2 1 # 5 Issues NULL 0 # 6 issuestrack 5 1 # 7 Help NULL 0 # 8 helpneeded 7 1 #
thanx提前
答
试着看一下你选择了 “XML” 的条款。既然我同意这看起来像功课,你将不得不自己挖掘一下。祝你好运!
听起来像是对我的功课问题。也可以更好地呈现。 – dtech 2011-03-19 09:39:10
@dtech我搜索了很多网站..我发现他们使用Itreecategory或asp.net菜单控件,以及其他事情,我不应该使用...所以我最终决定o张贴我的问题在这里 – bhargav 2011-03-19 09:57:11
买一本关于网络的书在C#和ASP.net中开发... – Powertieke 2011-03-19 11:54:03