ASP.NET DropDownList控件的使用方法
更新時間:2010年04月12日 00:07:00 作者:
ASP.NET DropDownList控件的使用方法,學習asp.net的朋友沒用過這個控件的朋友可以參考下。
1. 數(shù)據(jù)綁定
this.DropDownList1.DataSource = CategoryManager.getCategories();
DropDownList1.DataValueField = "id";//用來設置下拉列表選中的 Value 值
DropDownList1.DataTextField = "name";//為下拉列表選項顯示的值
DropDownList1.DataBind();
2.讀取數(shù)據(jù)
int categoryId = int.Parse(this.DropDownList1.SelectedItem.Value);//獲取下拉列表中選中的值
復制代碼 代碼如下:
this.DropDownList1.DataSource = CategoryManager.getCategories();
DropDownList1.DataValueField = "id";//用來設置下拉列表選中的 Value 值
DropDownList1.DataTextField = "name";//為下拉列表選項顯示的值
DropDownList1.DataBind();
2.讀取數(shù)據(jù)
復制代碼 代碼如下:
int categoryId = int.Parse(this.DropDownList1.SelectedItem.Value);//獲取下拉列表中選中的值
您可能感興趣的文章:
- asp.net 讀取xml文件里面的內容,綁定到dropdownlist中
- asp.net使用DataSet的ReadXml讀取XML文件及Stream流的方法
- ASP.NET讀取XML文件4種方法分析
- Javascript+XMLHttpRequest+asp.net無刷新讀取數(shù)據(jù)庫數(shù)據(jù)
- ASP.NET中讀取XML文件信息的4種方法與示例代碼
- ASP.NET MVC DropDownList數(shù)據(jù)綁定及使用詳解
- ASP.NET MVC中為DropDownListFor設置選中項的方法
- ASP.NET Ajax級聯(lián)DropDownList實現(xiàn)代碼
- asp.net DropDownList自定義控件,讓你的分類更清晰
- (asp.net c#)DropDownList綁定后顯示對應的項的兩種方法
- ASP.NET筆記之 ListView 與 DropDownList的使用
- asp.net實現(xiàn)XML文件讀取數(shù)據(jù)綁定到DropDownList的方法
相關文章
詳解Asp.net 5中的ApplicationBuilder
這篇文章介紹了Asp.net 5中的ApplicationBuilder,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-01-01ASP.NET web.config 配置節(jié)點詳解
這篇文章主要介紹了ASP.NET web.config 節(jié)點的配置,講解的非常詳細,需要的朋友可以參考下。2016-06-06創(chuàng)建ASP.NET?Core?Web應用程序并介紹項目模板
這篇文章介紹了創(chuàng)建ASP.NET?Core?Web應用程序的方法,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-02-02