本文介绍了从动态BindingList获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我有一个BindingList< dynamic>我希望循环并使用下面的代码获取值,我在一些示例中找到但是PropertyInfo值pi返回null。



任何帮助表示赞赏



Hi
I have a BindingList<dynamic> that I wish to loop through and obtain the values using the code below which I found in some examples but the PropertyInfo value pi is returning null.

Any assistance appreciated

var planData = (BindingList<dynamic>)Session["fgtPlanData"];
foreach (var pdat in planData)
{
    PropertyInfo pi = pdat.GetType().GetProperty("CompanyId");
    var gCell = pi.GetValue(pdat);
}

推荐答案

PropertyInfo pi = pdat.GetType().GetProperty("CompanyId");





1.没有任何与CompanyId名称相关的财产。

2.如果有名称为CompanyId的财产那么它不公开。



由于Type.GetProperty()方法只返回带有提供名称的公共属性。


这篇关于从动态BindingList获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 10:21