B
Brad
I have a web service which returns a collection of class object (see below).
I want to consume this service in another web application by binding it to a
List control The data returns from the web service, however when I bind
the data I get the following error
****
DataBinder.Eval: 'UserServices.User' does not contain a property with the
name FirstName.
****
Debugging I see that the list controls data source is a System.Array with
all of my data; each array element does indeed have an object with the
correct properties and FirstName is a public property/string. What am I
missing?
Brad
(cross posted to microsoft.public.dotnet.framework.aspnet
&
microsoft.public.dotnet.framework.aspnet.webservices
)
Code examples
==================================
Web Service (example only...real code is more and pulls data from database)
==================================
Public Class User
Public UserID as integer
Public FirstName as string
End class
Public Class UserServices
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function GetUsers(ByVal appName As String) As User()
Dim myUsers(1) as New User
Dim userA as New User
userA.UserID = 1
userA.FirstName = "Fred"
myUsers(0) = userA
Dim userB as New User
userB.UserID = 2
userB.FirstName = "Barney"
myUsers(1) = userB
return myUsers
End Function
==================================
Consumer code
==================================
Dim svc As New Services.UserServices
Dim ui() As svc.UserInfo = ps.GetUsers()
UserList.DataTextField = "FirstName"
UserList.DataValueField = "UserID"
UserList.DataSource = ui
UserList.DataBind()
I want to consume this service in another web application by binding it to a
List control The data returns from the web service, however when I bind
the data I get the following error
****
DataBinder.Eval: 'UserServices.User' does not contain a property with the
name FirstName.
****
Debugging I see that the list controls data source is a System.Array with
all of my data; each array element does indeed have an object with the
correct properties and FirstName is a public property/string. What am I
missing?
Brad
(cross posted to microsoft.public.dotnet.framework.aspnet
&
microsoft.public.dotnet.framework.aspnet.webservices
)
Code examples
==================================
Web Service (example only...real code is more and pulls data from database)
==================================
Public Class User
Public UserID as integer
Public FirstName as string
End class
Public Class UserServices
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function GetUsers(ByVal appName As String) As User()
Dim myUsers(1) as New User
Dim userA as New User
userA.UserID = 1
userA.FirstName = "Fred"
myUsers(0) = userA
Dim userB as New User
userB.UserID = 2
userB.FirstName = "Barney"
myUsers(1) = userB
return myUsers
End Function
==================================
Consumer code
==================================
Dim svc As New Services.UserServices
Dim ui() As svc.UserInfo = ps.GetUsers()
UserList.DataTextField = "FirstName"
UserList.DataValueField = "UserID"
UserList.DataSource = ui
UserList.DataBind()