2010-04-02 61 views
0

我打電話給webservice,如下所示。我必須使用這個webservice在gridview中顯示名稱,描述和url。gridview數據源問題

using sdi.amiller_v_vista; 

sdi.amiller_v_vista.DDCControl proxy1 = new sdi.amiller_v_vista.DDCControl(); 
sdi.amiller_v_vista.DDCReturnGetAll ret = proxy1.GetAllDDCs(x, y); 

foreach (sdi.amiller_v_vista.DDCInfo2 di2 in ret.DDCs) 
{ 
    GridView1.DataSource = I have to assign the di2 values(di2 is having name, description and url for each ddc) to gridview datasource 

    //GridView1.DataSource = ret.DDCs[i] throws an error Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource. 

    GridView1.DataBind(); 
} 

從WSDL元數據,我可以得到follwing信息

public DDCReturnGetAll GetAllDDCs(Guid accountId, Guid authToken); 

public class DDCReturnGetAll : DDCReturnBase 
{ 
    public DDCReturnGetAll(); 
    public DDCInfo2[] DDCs { get; set; } 
} 

public class DDCInfo2 
{ 
    public DDCInfo2(); 
    public BrandingType brandingType { get; set; } 
    public string ChargebackName { get; set; } 
    public string CollectorName { get; set; } 
    public string Description { get; set; } 
    public string URL { get; set; } 
} 

回答

0

它很難從你的樣品說,但你可能想要做類似的東西來代替它:

foreach (sdi.amiller_v_vista.DDCInfo2 di2 in ret.DDCs) { 
    GridView1.DataSource = I have to assign the di2 values to gridview datasource 
    //GridView1.DataSource = ret.DDCs[i] throws an error Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource. 
    GridView1.DataBind(); 
} 

與此:

GridView1.DataSource = ret.DDCs 
    GridView1.DataBind(); 
+0

謝謝喲它工作。 :) – xrx215 2010-04-02 17:44:47