zoukankan      html  css  js  c++  java
  • 有一个无效 SelectedValue,因为它不在项目列表中。异常

     #region 事件: 选择一级类型
        protected void DropClassType_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
               string droptwo = "select * from [ClassType] where [ClassPid]=" + Convert.ToInt32(this.DropClassType.SelectedValue) + "";
               DataTable dtclasstwo = DataBase.ExecuteDataTable(droptwo, CommandType.Text, null);
                if (dtclasstwo != null)
                {
                    this.dropClasstwo.DataSource = dtclasstwo;
                    this.dropClasstwo.DataTextField ="ClassName";
                    this.dropClasstwo.DataValueField ="ClassId";
                    this.dropClasstwo.DataBind();
                }
                else
                {
                    this.dropClasstwo.Items.Clear();
                    this.dropClasstwo.Items.Add("");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion


    //显示初始值
     protected void dropClasstwo_DataBound(object sender, EventArgs e)
        {
            dropClasstwo.Items.Insert(0, new ListItem("", "")); //原因listitem双引号里面不能有空格
            dropClasstwo.Text = "";

        }

  • 相关阅读:
    WebForm中使用MVC
    CPAN镜像使用帮助
    关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
    XML之命名空间的作用(xmlns)
    xml相关术语说明
    .NET Core系列 : 1、.NET Core 环境搭建和命令行CLI入门
    BZOJ3734 : [Ontak2013]Miny
    BZOJ3448 : [Usaco2014 Feb]Auto-complete
    BZOJ3476 : [Usaco2014 Mar]The Lazy Cow
    BZOJ3619 : [Zjoi2014]璀灿光华
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/1208957.html
Copyright © 2011-2022 走看看