zoukankan      html  css  js  c++  java
  • EF做数据绑定时一些神奇问题

    1.使用代码对绑定控件附值后需要调用BindingSource1.EndEdit(),以提交编辑到对应的数据源

    2.有总数、金额、单价三个输TextBox,结果发现每次切换表格选中行时,记录老变成修改状态,找了半天发现是因为
    在总数,金额的TextChanged中会自动计算单价并其设置txtUnitPrice.Text=xxx.xx,引起的


    解决代码

                    decimal amount = 0;
                    decimal totalMoney = 0;
                    if (decimal.TryParse(amountTextBox.Text, out amount)
                       && decimal.TryParse(totalMoneyTextBox.Text, out totalMoney)
                       && amount != 0
                      )
                    {
                        var curV= (totalMoney / amount).ToString("0.00");

                        var curObj = BindingSrc.Current as BuyRecord;
                        if (curObj != null && curObj.UnitPrice.HasValue)
                        {
                            if (curObj.UnitPrice.Value.ToString("0.00") == curV)
                            {
                                return;
                            }
                        }
                        unitPriceTextBox.Text = curV;
                        this.buyRecordBindingSource.EndEdit();

                    }

  • 相关阅读:
    js正则小记
    github相关
    js设置 获取 删除cookie
    js传递数据一些方式
    js call()方法
    DOM节点相关操作(兼容)
    git 常用命令总结
    js中的this指向
    angular 中 directive中的多个指令
    指令中 controller && controllerAs
  • 原文地址:https://www.cnblogs.com/wdfrog/p/2650986.html
Copyright © 2011-2022 走看看