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

  • 相关阅读:
    使用 media 实现响应式布局
    Django组件的中间件
    Django组件的cookie和 session,用户认证组件
    Django的文件上传和分页
    Ajax
    Django模型层的多表操作(2)
    Django模型层的多表操作(1)
    Django的查询表记录
    Django2.0版本的路由层和ORM但表操作
    Django的路由层,视图层和模版层
  • 原文地址:https://www.cnblogs.com/emanlee/p/1669403.html
Copyright © 2011-2022 走看看