Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何从args.getDataKeyValue中的对象获取值_.net - Fatal编程技术网

.net 如何从args.getDataKeyValue中的对象获取值

.net 如何从args.getDataKeyValue中的对象获取值,.net,.net,现在假设CompanyName是一个对象,我想从args.getDataKeyValue(“CompanyName”)中获取一个字段的值。这可行吗 function RowSelected(sender, args) { document.getElementById("<%= Label1.ClientID %>").innerHTML = "<b>CustomerID: </b>

现在假设CompanyName是一个对象,我想从args.getDataKeyValue(“CompanyName”)中获取一个字段的值。这可行吗

       function RowSelected(sender, args)
        {
            document.getElementById("<%= Label1.ClientID %>").innerHTML =
             "<b>CustomerID: </b>" + args.getDataKeyValue("CustomerID") +
             "<br />" +
             "<b>CompanyName: </b>" + args.getDataKeyValue("CompanyName");
        }
所选函数行(发送方,参数)
{
document.getElementById(“”).innerHTML=
CustomerID:+args.getDataKeyValue(“CustomerID”)+
“
”+ “公司名称:”+args.getDataKeyValue(“公司名称”); }
我想,你可以这样做:

object companyName = args.getDataKeyValue("CompanyName");
Type companyNameType = companyName.GetType();
var companyNamePropValue = companyNameType.GetProperty("YourPropertyName").GetValue(companyName, null);

尽管这个问题有点陈旧,但我解决这个问题的方法是将KeyValue强制转换为ObjectType

CompanyName companyName = args.getDataKeyValue("CompanyName") as CompanyName;
然后,您将从companyName对象中的KeyValue获取所有属性