2015-01-06 56 views
0

Gateway.cs頁屬性列表中的數據沒有顯示

public class gatewayConnectionPropertyData 
{ 

public string url { get; set; } 
public int type { get; set; } 
public string service_desc { get; set; } 

} 

protected void btnAddEdit_Click(object sender, EventArgs e) 
{ 

gatewayConnectionPropertyData proposal = new gatewayConnectionPropertyData(); 
proposal.url = "/testproposal.xml"; 
proposal.type = 13; 
proposal.service_desc = "proposal"; 

gatewayConnectionPropertyData utility = new gatewayConnectionPropertyData(); 
proposal.url = "/testUtulity.xml"; 
proposal.type = 12; 
proposal.service_desc = "utility"; 

gatewayConnectionPropertyData intelligence = new gatewayConnectionPropertyData(); 
proposal.url = "/testinteligence.xml"; 
proposal.type = 53; 
proposal.service_desc = "intelligence"; 


List<gatewayConnectionPropertyData> mydataList = new List<gatewayConnectionPropertyData>(); 
gatewayConnectionPropertyDataList.Add(proposal); 
gatewayConnectionPropertyDataList.Add(utility); 
gatewayConnectionPropertyDataList.Add(intelligence); 

} 

mydataList總是算不過3只出現升AST添加的項目我可以看不到所有提交的數據在那裏我錯過了什麼我做需要改變。如果有任何意見,我可以在我的身邊申請更好的解決方案,以創建屬性列表模型

謝謝。

+0

您正在'gatewayConnectionPropertyDataList'中添加項目是什麼?而不是'mydataList' –

回答

0

首先,您要在gatewayConnectionPropertyDataList(我不確定它是什麼)中添加項目,但是如果您期待mydataList中的數據,則只需添加此變量。此外,您可以使用collection initializers這樣的: -

List<gatewayConnectionPropertyData> mydataList = 
           new List<gatewayConnectionPropertyData> 
{ 
    new gatewayConnectionPropertyData { url = "/testproposal.xml", type = 13, 
              service_desc = "proposal" }, 
    new gatewayConnectionPropertyData { url = "/testUtulity.xml", type = 12, 
              service_desc = "utility" }, 
    new gatewayConnectionPropertyData { url = "/testinteligence.xml", type = 53, 
              service_desc = "intelligence" }, 
};