zoukankan      html  css  js  c++  java
  • 对COMBOX控件的SelectedValue为空的问题

    //实践表明,不初始化combox控件的数据源,则无法对SelectedValue进行赋值
                        //因为赋值后赋值等式右边虽然有值,但SelectedValue确仍为空,具体什么原因不明?
                        initializeDatasource();
                        
                        dtp_makeDate.Text = item.WeighingDate.ToString();
                        txt_weighingTime.Text = item.WeightingTime;
    
                        cmb_custName.SelectedValue =item.CusCode.ToString();
                        cmb_custName.Text = item.CusName;

    看有个网站,有如下解释:

    The SelectedValue property is used when you have linked the ComboBox to a data source, and want to return a value other than what is displayed.

    For example, say you have a table called "City" which is made up of two fields, "ZipCode" and "CityName."  You want to display to your application users the "CityName" value, but you are interested in storing the "ZipCode" value for the selected item.

    With your ComboBox control, you set the following properties:

    ComboBox.DataSource=City

    ComboBox.DisplayMember=CityName

    ComboBox.ValueMember=ZipCode

    The ComboBox.SelectedItem will be CityName, but ComboBox.SelectedValue will be ZipCode.

  • 相关阅读:
    UML统一建模语言笔记
    从零开始学JavaWeb
    也谈微信小程序
    Memcached,你懂的
    一个简单的配置管理器(SettingManager)
    我的AngularJS 学习之旅
    .NET Core 跨平台
    ASP.NET Core 中间件自定义全局异常处理
    面试必考题——递归解题套路
    程序员着装指南
  • 原文地址:https://www.cnblogs.com/windy3417/p/13883346.html
Copyright © 2011-2022 走看看