Error : Complex DataBinding accepts as a data source either an IList or an IListSource

  • Thread starter Thread starter BS
  • Start date Start date
B

BS

Hello everybody

I'm calling a webservice that returns complex data.
The goal is to populate a datagrid with it.

Using a loop for each record found ( such as For i = 0 To
oResponse.historicalData.Length - 1 )
no problem to load a datagrid.

However, when I try to bind directly the datasource to the web service
complex datatype, I have the following error:
Complex DataBinding accepts as a data source either an IList or an
IListSource

Any idea what I have to do to the webservice records in order for my
datagrid to load ?


Here is the code used to pupulate the grid.

Dim oES As SomeWebservice.EquipmentService = New
SomeWebservice.EquipmentService
Dim oResponse As SomeWebservice.responseHistoricalData = New
SomeWebservice.responseHistoricalData


'set response object with service response
oResponse = oES.historicalData(oRequest)

DataGrid1.DataSource = oResponse
 
Hi,

You can an arraylist, collection, or array to a datagrid. Any
poperties in a class contained in class stored in one of the above will be
shown in the datagrid. What format are you getting you data in?

Ken
 
Hi,

What is the format of this. I need to know more about
responseHistoricalData

Dim oResponse As SomeWebservice.responseHistoricalData = New
SomeWebservice.responseHistoricalData

Ken
 
Here is the definitions: They are most of the time "complex data type".

----------------------------------------------------------------------------
---------------------------------------------------------
'<remarks/>

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://www.XXXXXX.c
om/integration/2.0")> _

Public Class responseHistoricalData

Inherits LegacyApiOutput


'<remarks/>

<System.Xml.Serialization.XmlElementAttribute("historicalData")> _

Public historicalData() As historicalData

End Class
----------------------------------------------------------------------------
---------------------------------------------------------

'<remarks/>

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://www.XXXXXX.c
om/integration/2.0")> _

Public Class historicalData


'<remarks/>

Public equipmentID As String


'<remarks/>

Public terminalID As String


'<remarks/>

Public arrivalTimestamp As String


'<remarks/>

Public position As positionAndProximityWithTimestamp


'<remarks/>

Public serviceMeterHours As serviceMeterHoursWithTimestamp

End Class



----------------------------------------------------------------------------
---------------------------------------------------------

'<remarks/>

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://www.XXXXXX..
com/integration/2.0")> _

Public Class positionAndProximityWithTimestamp

Inherits positionWithTimestamp


'<remarks/>

<System.Xml.Serialization.XmlElementAttribute("proximity")> _

Public proximity() As proximity

End Class

----------------------------------------------------------------------------
---------------------------------------------------------



'<remarks/>

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://www.XXXXXX..
com/integration/2.0")> _

Public Class proximity


'<remarks/>

Public type As proximityType


'<remarks/>

Public location As String


'<remarks/>

Public [region] As String


'<remarks/>

Public postalCode As String


'<remarks/>

<System.Xml.Serialization.XmlElementAttribute("kilometersFromLocation",
GetType(System.Decimal)), _

System.Xml.Serialization.XmlElementAttribute("milesFromLocation",
GetType(System.Decimal)), _

System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")> _

Public Item As Decimal


'<remarks/>

<System.Xml.Serialization.XmlIgnoreAttribute()> _

Public ItemElementName As ItemChoiceType1


'<remarks/>

Public directionFromLocation As proximityDirection

End Class



----------------------------------------------------------------------------
---------------------------------------------------------
 
Hi,


First off if you can only bind to properties in a class class
not public variables.

For example change
Public equipmentID As String

To
Private mstr_equipmentId As String

Public Property equipmentID() As String
Get
Return mstr_equipmentId
End Get
Set(ByVal Value As String)
mstr_equipmentId = Value
End Set
End Property

Second Try loading the data into an arraylist and bind to that.

oResponse = oES.historicalData(oRequest)
dim arBindto as new ArrayList
arBindto.Add(oResponse)
DataGrid1.DataSource = arBindto

Hope that helps.

Ken
-------------------
 
Thank you Ken,

yes I already tried your suggestion of creating a "buffer" class for each
webservices functions called.
It works very well.

But that method did not seems efficient to me...add a new layer in between
the 2.Also, I should maybe mention that we do not have control to the web
service definitions...we did not write it. I have to use it as is.

But if that is the only solution...

Thank you very much for your help !
 
HI BS,

In my opinion is the solution Ken advises you is not inefficient however
very sufficient.

Cor
 
Back
Top