无法将 ArrayCollection 设置为等于 Result.Event
我试图将数组集合设置为等于包含数组集合的 event.result,但我的数组集合始终为空。 event.result 不为空,因为我可以将其指定为数据网格的数据提供者并且可以正常工作(正确显示数据)
var ac = new ArrayCollection();
ac = event.result as ArrayCollection;
dgSomeDataGrid.dataProvider = event.result;
知道我做错了什么吗?
I'm trying to set an array collection equal to a event.result that contains an array collection, but my array collection keeps coming up null. The event.result isn't empty because I can assign it as the dataprovider for a datagrid and that works (shows data correctly)
var ac = new ArrayCollection();
ac = event.result as ArrayCollection;
dgSomeDataGrid.dataProvider = event.result;
Any idea on what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果对象的类型不正确,
as
运算符将返回 null。无论 event.result 是什么,它都不是ArrayCollection
。你知道它是什么吗?一种查找方法:如果它是一个
Array
,您可以创建一个新集合:更多信息会很好。
The
as
operator will return null if the object is not of the correct type. Whatever event.result is, it isn't anArrayCollection
. Do you know what it is? One way to find out:If it is an
Array
, you can create a new collection:More info would be nice.
确保您的结果是
ArrayCollection
!这一行:没有任何类型相关的操作。此行是否有效:
?
放置断点并检查数据的真实类型。
Make sure your result is
ArrayCollection
! This line:hasn't any type related operations. Does this line work:
?
Place s breakpoint and check the real type of data.
结果应该是什么?如果“as”运算符无法转换您尝试转换的任何内容,则它始终返回 null。我的猜测是,你的结果返回了不同的东西(数组、对象、XML?),而你试图让它变得不一样。只需使用 debug 来检查类型即可。
What is the result suppose to be? The 'as' operator will always return null if it can't cast whatever you're trying to cast. My guess is that your result is returning something different (Array, Object, XML?) and you're trying to make it something that it's not. Just use debug to check the type.