C# 如何在asp.net页面上快速显示复杂数据

C# 如何在asp.net页面上快速显示复杂数据,c#,asp.net,web-services,data-binding,C#,Asp.net,Web Services,Data Binding,如何在asp.net页面中显示复杂的数据对象?实际上,下面的类是只读的,数据需要显示在屏幕上,以便代理可以告诉客户他们需要支付多少。我不想写很多代码来规范它并在页面上显示它。此数据由web服务方法调用返回 public class FeeInfo { private string countryInfoTextField; public string CountryInfoTextField { get{return this.countryInfoTextField;} se

如何在asp.net页面中显示复杂的数据对象?实际上,下面的类是只读的,数据需要显示在屏幕上,以便代理可以告诉客户他们需要支付多少。我不想写很多代码来规范它并在页面上显示它。此数据由web服务方法调用返回

public class FeeInfo {

private string countryInfoTextField;
public string CountryInfoTextField
{
    get{return this.countryInfoTextField;}
    set{this.countryInfoTextField= value;}
}
private stringfeeInfoTextField;
public string FeeInfoTextField
{
    get{return this.feeInfoTextField;}
    set{this.feeInfoTextField= value;}
}
private string taxInfoTextField;
public string TaxInfoTextField
{
    get{return this.taxInfoTextField;}
    set{this.taxInfoTextField = value;}
}

private string additionalInfoTextField;
public string additionalInfoText
{
    get{return this.additionalInfoTextField;}
    set{this.additionalInfoTextField = value;}
}

private PromotionInfo[] promotionInfoField; //Class

private SendAmountInfo sendAmountsField; //Class

private EstimatedReceiveAmountInfo receiveAmountsField; //Class

/// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("promotionInfo")]
        public PromotionInfo[] promotionInfo {
            get {
                return this.promotionInfoField;
            }
            set {
                this.promotionInfoField = value;
            }
        }

        /// <remarks/>
        public SendAmountInfo sendAmounts {
            get {
                return this.sendAmountsField;
            }
            set {
                this.sendAmountsField = value;
            }
        }

        /// <remarks/>
        public EstimatedReceiveAmountInfo receiveAmounts {
            get {
                return this.receiveAmountsField;
            }
            set {
                this.receiveAmountsField = value;
            }
        }
}
公共类FeeInfo{
私有字符串countryInfoTextField;
公共字符串CountryInfoTextField
{
获取{返回this.countryInfoTextField;}
设置{this.countryInfoTextField=value;}
}
私有stringfeeInfoTextField;
公共字符串FeeInfoTextField
{
获取{返回this.feeInfoTextField;}
设置{this.feeInfoTextField=value;}
}
私有字符串文本字段;
公共字符串文本字段
{
获取{返回this.taxInfoTextField;}
设置{this.taxInfoTextField=value;}
}
私有字符串additionalInfoTextField;
公共字符串附加信息文本
{
获取{返回this.additionalInfoTextField;}
设置{this.additionalInfoTextField=value;}
}
私有PromotionInfo[]PromotionInfo字段;//类
私有sendamountfo sendAmountsField;//类
private EstimatedReceiveMountInfo ReceiveAmounts字段;//类
/// 
[System.Xml.Serialization.XmlElementAttribute(“promotionInfo”)]
公共促销信息[]促销信息{
得到{
返回此.promotionInfo字段;
}
设置{
this.promotionInfo字段=值;
}
}
/// 
公共SendAmountInfo sendAmounts{
得到{
返回此.sendAmountsField;
}
设置{
this.sendAmountsField=值;
}
}
/// 
公共估计接收金额信息接收金额{
得到{
返回此.receiveAmounts字段;
}
设置{
this.receiveAmountsField=值;
}
}
}

我将上面的内容转换为一个列表并将其绑定到gridview,但我看到的只是4个字段,而不是最后3个复杂属性。在屏幕上显示这些数据的快捷方式是什么?

在FeeInfo中添加一个toList方法

public List<FeeInfo> toList(){
    var retList;
    var props = this.GetType().GetProperties();
    foreach(var prop in props) {
        if(prop.propertyType.IsArray) 
            for(int i=0;i<prop.length;i++) 
                 retList.add(new GridView(prop.GetValue[i]);
        else if(prop.propertyType.isClass) 
            retList.Add(new Gridview(prop.GetValue()));
        else retList.Add(prop.GetValue());
    }
    return retList;
}
public List toList(){
var-retList;
var props=this.GetType().GetProperties();
foreach(道具中的var道具){
if(prop.propertyType.IsArray)

对于(int i=0;最后三个是私有变量。它们不会暴露在类外。@AmitKumarGhosh这些变量也有3个公共属性,就像其他变量一样。很抱歉,我在粘贴代码时错过了这一点。我刚刚更新了代码。实际上,为了使其能够编译,需要进行一些调整。让al将类似Java的构造转换为一般可取的C#约定。我对可取的约定更感兴趣。使其看起来更好。VS Community是从idk开始安装的,当我得到新的工作笔记本时。@Narcil FeeInfo是通过web服务方法返回的,如果我更改reference.cs文件,每次更新引用时,任何我所做的一切都将失去。