首页 > 其他分享 >'ddlCities' has a SelectedValue which is invalid because it does not exist in the list of

'ddlCities' has a SelectedValue which is invalid because it does not exist in the list of

时间:2023-11-09 12:32:38浏览次数:34  
标签:because DataTextField items GetAll list exist ddlCities SelectedValue

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();



标签:because,DataTextField,items,GetAll,list,exist,ddlCities,SelectedValue
From: https://blog.51cto.com/emanlee/8276181

相关文章

  • 线程安全集合(JDK1.5之前和之后)、CopyOnWriteArrayList、CopyOnWriteArraySet
    JDK1.5之前JDK1.5之前:Collections.synchronizedList JDK1.5之后CopyOnWriteArrayList   CopyOnWriteArraySet    ......
  • CMake多个CMakeLists.txt共同合作编译一个C++项目
    一、概述在C++项目比较大或者要根据不同的规则生成不同的执行文件或者动态库/静态库的时候。单独的CMakeLists.txt会变的比较复杂,此时可以利用CMakeLists.txt的父子关系分目录分模块的进行编译及输出。就相当于项目模块化编译参考博客:【大丙课堂】二、具体实现......
  • ArrayList的contains()方法的性能问题及优化方法
    背景今天定位一个接口耗时问题,通过日志定位到在数据库查询完毕后,中间一段逻辑耗时很长有十几秒的样子,发现是循环中使用ArraysList中的contains方法,当循环数量级变得很大时,执行时间变得不可控。代码示例//有5万个门店List<Store>storeList=storeMapper.se......
  • Uncaught TypeError: Cannot read property ‘addEventListener‘ of null 求助!!!!!!
    今天在项目中遇到个问题如下:vue项目中public的index.html文件script标签引入了一个外部的js文件,里面有一个方法每次调用的时候都会报错UncaughtTypeError:Cannotreadproperty‘addEventListener‘ofnull,网上查的所有办法都试过了:跟标签摆放先后位置,放到onload方法中都没......
  • python循环遍历字典: title_content_list.append([key, value])print(ti
    示例示例Python循环遍历字典的方法有以下几种:使用for...in循环:Python循环遍历字典的方法有以下几种:1.使用for...in循环:pythondict={'name':'Tom','age':20,'gender':'male'}#遍历所有的键forkeyindict:print(key)#遍历所有的值forvalueindict.values......
  • JAVA遍历list是对其操作
    @Testpublicvoidremove(){ArrayList<String>list=newArrayList<>();list.add("php");list.add("java");list.add("php");list.add("php");list.add(......
  • Displaying multiple columns in a HTML Listbox Control in ASP.Net
    REF:http://forums.aspfree.com/net-development-11/displaying-multiple-columns-in-a-html-listbos-control-in-asp-19062.html listboxcolumnspacingsolutionFINALLY!!!IKnowsomanypeoplehavehadthisproblem.Butfinallyisolveditwithyourbasicmonos......
  • 37-Vue脚手架-nextTick(使用nextTick优化TodoList案例)
    this.$nextTick(十分常用的功能)语法:this.$nextTick(回调函数)作用:在下一次DOM更新结束后执行其指定的回调什么时候用:当改变数据后,要基于更新后的新DOM进行某些操作时,要在nextTick所指定的回调函数中执行 案例:使用 $nextTick优化TodoList案例,在UserItem中添加一个编辑按......
  • vue-test -----ListDemo 列表渲染
    <template><h3>数组</h3><button@click="addnums">添加数据</button><pv-for="(item,index)innums":key="index">{{item}}</p></template><script>exportdefault{name:......
  • Configuration failed because libxml-2.0 was not found. Try installing:
     001、linux中R语言中安装“devtools”报错如下:Configurationfailedbecauselibxml-2.0wasnotfound.Tryinstalling: 002、解决方法:[root@pc1~]#yuminstalllibxml2-devel##根据提示安装 。 ......