2010-04-02 3 views
0

Я звоню в веб-сервис следующим образом. Мне нужно отображать имя, описание и URL-адрес в gridview с помощью этого веб-сервиса.gridview datasource issue

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

thank yo u работает. :) – xrx215