自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

DropDownList顯示的C#遞歸實(shí)現(xiàn)淺析

開發(fā) 后端
DropDownList顯示是如何通過C#遞歸來實(shí)現(xiàn)的呢?那么具體的步驟是什么呢?我們需要注意什么呢?讓我們來看看本文對于C#遞歸實(shí)現(xiàn)DropDownList顯示實(shí)例。

C#遞歸實(shí)現(xiàn)DropDownList顯示之前首先我們來看看對于DropDownList的理解,對于有些形式的輸入,用戶必須從適用選項(xiàng)列表中選擇一個(gè)選項(xiàng)。例如,軟件公司可能要?jiǎng)?chuàng)建一個(gè)支持網(wǎng)站,用戶可以在其中找到關(guān)于該公司各種軟件產(chǎn)品的常見問題的答案。用戶尋找問題的答案時(shí),如果在用戶搜索的關(guān)鍵字旁邊,可以選擇問題是針對于哪個(gè)軟件產(chǎn)品的,將有助于他更容易找到問題的答案。

在這種情況下,適合收集這種信息輸入的Web控件是DropDownList。DropDownList Web控件創(chuàng)建一個(gè)包含多個(gè)選項(xiàng)的下拉列表,用戶可以從中選擇一個(gè)選項(xiàng),那讓我們來看看DropDownList顯示的C#遞歸實(shí)現(xiàn)實(shí)例:

  1.  /**//// <summary>  
  2.  
  3. ////DropDownList顯示的C#遞歸實(shí)現(xiàn)  
  4. /// 綁定文件分類  
  5. /// </summary>  
  6. public void bind()  
  7. {  
  8. //獲取數(shù)據(jù)集  
  9. DataSet ds = new DataSet();  
  10. ds = ec.ExecuteSelectCmmond(  
  11. "select * from t_Column where U_UserID='" +   
  12. HttpContext.Current.Request.Cookies["NameID"].Value + "'", ds);  
  13. BindingCWAList(DropDownList1, ds);  
  14. }  
  15. private void BindingCWAList(DropDownList ddlID, DataSet ds)   
  16. //ddlID是DropDownList控件的ID   
  17. {  
  18. DropDownList1.Items.Clear();  
  19. //此處創(chuàng)建頂極分類,Value=0(如不需要,可以刪除此行)   
  20. ddlID.Items.Add(new ListItem("請選擇目錄""0"));  
  21. InitList(ddlID, 0, ds, "");  
  22. }  
  23.  
  24.  
  25. private void InitList(DropDownList ddlID,   
  26. int parentID, DataSet catagoryDS, string indent)  
  27. {  
  28. //Select后邊的是DataSet里面的列名   
  29. System.Data.DataRow[] currRows =   
  30. catagoryDS.Tables[0].Select("ColumnFatherld=" +   
  31. parentID.ToString(), "ColumnFatherld ASC");  
  32. int count = currRows.Length;  
  33. DataRow catagoryRow;  
  34. for (int i = 0; i < count; i++)  
  35. {  
  36. catagoryRow = currRows[i];  
  37. System.Web.UI.WebControls.ListItem item =   
  38. new System.Web.UI.WebControls.ListItem(indent +   
  39. catagoryRow["ColunmnName"].ToString(),   
  40. catagoryRow["ColumnId"].ToString());  
  41. ddlID.Items.Add(item);  
  42. InitList(ddlID, Int32.Parse(  
  43. catagoryRow["ColumnId"].ToString()),   
  44. catagoryDS, indent + "……");  
  45. }  
  46. }  

DropDownList顯示的C#遞歸實(shí)現(xiàn)的基本內(nèi)容就向你介紹到這里,希望對你了解和學(xué)習(xí)DropDownList顯示的C#遞歸實(shí)現(xiàn)有所幫助。

【編輯推薦】

  1. C#程序設(shè)計(jì)關(guān)閉Windows窗體淺析
  2. C#程序設(shè)計(jì)獲取系統(tǒng)信息的Windows窗體淺析
  3. C#遞歸算法理解的實(shí)例分析
  4. C#遞歸思路的使用實(shí)例詳解
  5. C#遞歸函數(shù)應(yīng)用實(shí)例解析
責(zé)任編輯:仲衡 來源: 博客園
相關(guān)推薦

2009-09-02 17:24:44

C#關(guān)機(jī)代碼

2009-09-07 09:36:29

C# DisposeDispose方法

2009-08-26 09:54:45

C#打印預(yù)覽C#打印

2009-08-31 16:48:02

C#實(shí)現(xiàn)IDispos

2009-09-02 15:34:37

C#實(shí)現(xiàn)插件構(gòu)架

2009-09-01 18:29:24

C#實(shí)現(xiàn)多個(gè)接口

2009-08-18 09:49:00

C# listview

2009-08-12 16:26:30

C#讀取XML文檔

2009-09-07 14:00:57

C#抓取網(wǎng)頁

2009-08-27 18:09:49

C#接口的實(shí)現(xiàn)

2009-08-28 15:57:56

C#線程傳遞參數(shù)

2009-08-21 09:20:44

C#異步套接字

2009-09-09 11:29:32

C# TextBox事

2009-09-04 16:18:09

C# MSNMSN Messeng

2009-08-13 18:15:06

C#繼承構(gòu)造函數(shù)

2009-08-28 16:03:15

C#程序?qū)崿F(xiàn)鼠標(biāo)移動(dòng)

2009-09-11 12:41:41

C#類型轉(zhuǎn)換

2009-08-26 09:48:48

C#異步套接字

2009-07-31 18:28:46

實(shí)現(xiàn)C#顯示圖像

2009-08-25 15:52:27

C#工具欄
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號