zoukankan      html  css  js  c++  java
  • 'ddlXXX' has a SelectedIndex which is invalid because it does not exist in the list of items

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.ArgumentOutOfRangeException: 'ddlXXX' has a SelectedIndex which is invalid because it does not exist in the list of items.
    Parameter name: value
    Source Error:

    Line 269:        ddlxxx.DataTextField = "Name"
    Line 270:        ddlxxx.DataValueField = "id"
    Line 271:        ddlxxx.DataBind() 
    Line 272:        ddlxxx.Items.Insert(0, New ListItem("All", "-1"))
    Line 273:        ddlStudents.SelectedIndex = 0

    ============================

    listOrgs.Items.Clear();
    listOrgs.SelectedIndex = -1;
    listOrgs.SelectedValue = null;
    listOrgs.ClearSelection();     // Clears the selection to avoid the exception (only one of these should be enough but in my application I needed all..)
    listOrgs.DataSource = new Organization().DTListAll(SiteID);
    listOrgs.DataTextField = "OrganizationName"; 
    listOrgs.DataValueField = "OrganizationID"; 
    listOrgs.DataBind();

  • 相关阅读:
    go通道小案例
    go执行cmd命令并获取输出内容
    vue快速生成二维码
    vue.js数字简化 万转化k显示
    uniapp实现小程序获取用户信息
    实现图片预加载功能
    C# MD5加密字符串方法
    一个封装的 HttpClientHelper
    简易通过队列存储并异步打日志实现
    变量
  • 原文地址:https://www.cnblogs.com/emanlee/p/1669403.html
Copyright © 2011-2022 走看看