【问题标题】:How to Un-Bind a data source: DataBinding: 'System.String' does not contain a property with the name 'ALL'如何取消绑定数据源:DataBinding:“System.String”不包含名为“ALL”的属性
【发布时间】:2012-02-13 08:11:52
【问题描述】:

DropDownList2 循环将数据绑定到 DropDownList3,但如果我使用 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'."

}

请帮忙,这让我发疯了。

【问题讨论】:

    标签: c# asp.net drop-down-menu data-binding unbind


    【解决方案1】:

    在您的 .aspx 页面中,为“ALL”添加新的列表项。然后在DropDownList3的属性窗口中,设置AppendDataBoundItems = true。

    删除下面一行

    listDropDown3.Add("ALL");
    

    这应该可以解决您的问题。

    【讨论】:

      猜你喜欢
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多