ASP.NET DropDownListコントロールの使い方

434 ワード

1.データバインド
 
  
this.DropDownList1.DataSource = CategoryManager.getCategories();
DropDownList1.DataValueField = "id";// Value
DropDownList1.DataTextField = "name";//
DropDownList1.DataBind();

2.データの読み出し
 
  
int categoryId = int.Parse(this.DropDownList1.SelectedItem.Value);//