2012-02-13 14 views
0

DropDownList2はDropDownList3にデータをバインドするためにループしますが、エラーが発生します。 ":DataBinding: 'System.String '' DropDownList2を使用して別の値を選択すると、 'ALL'という名前のプロパティは含まれません。データソースのバインドを解除する方法:DataBinding: 'System.String'に 'ALL'という名前のプロパティが含まれていません

DropDownList2_SelectedIndexChanged(object sender, EventArgs e) 
{ 

DropDownList3.DataSource = null; 
DropDownList3.DataBind(); 
DropDownList3.Items.Clear(); 


//generic list 

listDropDown3.Clear(); 
listDropDown3.Add("ALL"); 


DropDownList3.DataSource = listDropDown3; 
DropDownList3.DataBind(); **** <<<=== pukes on DataBind() during second iteration: 

" DataBinding: 'System.String' does not contain a property with the name 'ALL'." 

} 

助けてください、これは私をナットにしてくれます。

答えて

1

.aspxページで、 "ALL"の新しいリスト項目を追加します。 DropDownList3のプロパティウィンドウで、AppendDataBoundItems = trueを設定します。

は、次の行これはあなたの問題を解決する必要があり

listDropDown3.Add("ALL"); 

を削除します。

関連する問題