zoukankan      html  css  js  c++  java
  • SelectedValue 失效

    /// <summary>
            /// 绑定代表下拉选项
            /// </summary>
            public void BindOwnerDataII(string unitId, string bindid)
            {
    
                BaseCore obj = new BaseCore();
                DataTable dt = obj.GetOwnerByBusiness(unitId);
                this.ddlOwner.DataSource = dt;
                this.ddlOwner.DataTextField = "fullname";
                this.ddlOwner.DataValueField = "systemuserid";
                this.ddlOwner.DataBind();
                this.ddlOwner.SelectedValue = bindid; 
                this.ddlOwner.Items.Insert(0, new ListItem("全部", "00000000-0000-0000-0000-000000000000"));
    
    }

    我的问题是 应该是由于 字符的大小写引起的, 因为 this.ddlOwner.SelectedValue = bindid;  bindid 为大写的GUID,但是 dt中的元素都是小写的,这里是什么原因我不知道,因为

    GetOwnerByBusiness(unitId);从数据库中取到的GUID全部为大写的.   

    改为使用下面的语句就看出问题来了,如果是大写的GUID会报错,所以把bindid 转换为小写了,这样就正常了.

      this.ddlOwner.Items.FindByValue(bindid.ToLower()).Selected = true;

  • 相关阅读:
    MongoDB入门
    MongoDB基础命令
    MongoDB查询
    MongoDB索引
    MongoDB聚合
    MongoDB进阶
    Elasticsearch简介与安装
    ElasticSearch索引
    shiro xml标准配置
    shiro双realm验证
  • 原文地址:https://www.cnblogs.com/BinBinGo/p/5094079.html
Copyright © 2011-2022 走看看