this.ddlCities.DataSource = GetAll_List();
this.ddlCities.DataTextField = "Name";
this.ddlCities.DataValueField = "Id";
this.ddlCities.DataBind();

错误:

'ddlCities' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

原因:

多次执行了绑定,因此会出现重复的ListItem。

解决方法:

(1)检查是否有多次绑定。

(2)添加 this.ddlCities.Items.Clear();

this.ddlCities.Items.Clear();

this.ddlCities.DataSource = GetAll_List();
this.ddlCities.DataTextField = "Name";
this.ddlCities.DataValueField = "Id";
this.ddlCities.DataBind();

相关文章:

  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
猜你喜欢
  • 2022-12-23
  • 2021-04-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-06-19
  • 2021-10-07
相关资源
相似解决方案