2011-03-19 109 views
1

您好我有一個無序列表<ul><li><ul><li>如何從數據庫表數據生成無序列表?

我做了一個表,以填補無序列表,但如何獲取這些數據轉化爲liul 表由家庭,組織(兒童政策,employeesdetails)等等..我如何填寫這些ulli的和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提前

+0

聽起來像是對我的功課問題。也可以更好地呈現。 – dtech 2011-03-19 09:39:10

+0

@dtech我搜索了很多網站..我發現他們使用Itreecategory或asp.net菜單控件,以及其他事情,我不應該使用...所以我最終決定o張貼我的問題在這裏 – bhargav 2011-03-19 09:57:11

+0

買一本關於網絡的書在C#和ASP.net中開發... – Powertieke 2011-03-19 11:54:03

回答

-1

試着看一下你選擇了 「XML」 的條款。既然我同意這看起來像功課,你將不得不自己挖掘一下。祝你好運!