2012-02-13 56 views
0

DropDownList2循環將數據綁定到DropDownList3,但出現錯誤「:DataBinding:'System.String '不包含名爲'ALL'的屬性。「,如果我使用DropDownList2來選擇不同的值。如何解除綁定數據源: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"); 

這應該解決您的問題。

相關問題