请教基础资料名称(多语)值更新事件e.NewValue取值方法?
金蝶云社区-nmgzjf
nmgzjf
0人赞赏了该文章 843次浏览 未经作者许可,禁止转载编辑于2016年08月20日 22:53:24

做了基础资料表单插件,值更新事件中

if (!e.Field.Key.ToString().Equals("FName")) return;
if (this.View.Model.GetValue("FName").ToString().IsEmpty()) return;//录入为空时忽略
if (e.NewValue.IsNullOrEmptyOrWhiteSpace()) return; //录入为空时忽略

第一步就是为空时忽略,竟然不行!e.NewValue.IsNullOrEmptyOrWhiteSpace()
e.NewValue.ToString()
"System.Object[]"

而string strHoustLocationName = e.NewValue.ToString();也不对!
调试信息如下,请教老师,该怎么取值,VB6转上来的,业务都熟,败在基本语法上了!
必须用这个吗?this.View.Model.GetValue("FName").ToString()
((e.NewValue) as Object[])[0]
Count = 2
[0]: {[Key, 2052]}
[1]: {[Value, 1234]}
((e.NewValue) as Object[])[1]
'((e.NewValue) as Object[])[1]' threw an exception of type 'System.IndexOutOfRangeException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233080
HelpLink: null
InnerException: null
Message: "索引超出了数组界限。"
Source: null
StackTrace: null
TargetSite: null
((e.NewValue) as Object[])[0]
Count = 2
[0]: {[Key, 2052]}
[1]: {[Value, 1234]}
((e.NewValue) as Object[])[0][0]
error CS0021: 无法将带 [] 的索引应用于“object”类型的表达式
((e.NewValue) as Object[])[0].ToString()
"{\"Key\":2052,\"Value\":\"1234\"}"

您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!

请选择打赏金币数 *

10金币20金币30金币40金币50金币60金币
可用金币: 0