Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2004

Tip: Looking for answers? Try searching our database.

Interesting Problem With WebService results and Repeater Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Lutz - 04 Dec 2004 13:35 GMT
I have written a web service to provide some back-end functionality to a Web
Site.  The web service returns lists of items.
If I use the webservice via a browser, it works fine and returns the results
in XML.
I then created the proxy for the Web Service in VS.NET. I can call the
webmethod fine and get an array of Items. (Although it's a local class to
the WebSite).

When I attempt to have a repeater control list the reults in a web form, I
get an error that the class Item does not contain a property called "Name".
I'm not sure where to go from here aside from attempting to convert the Item
array into something else manually.

---------
Quick Code Example

[Web Method]
public Item[] GetItems(string CategoryID)
{
   return ItemList(CategoryID);        // Helper function that constructs
the array
}

Class Item
{
   private string _name;
   Public Name
   {
       Get { return _name;};
       Set { _name = value}
   }

}
Dan Rogers - 06 Dec 2004 21:03 GMT
Hi Steve,

The array of items is probably setting up the item class to have fields
exposed directly instead of properties (which the form binding requires).  
To fix this, you need to make the proxy use a class that exposes the data
via properties instead of by field.  You can only do this by manually
changing the generated proxy.

For an example of what the item class needs to look like, run the schema
for your service interface thru the XsdObjectGen.exe tool that you can
download from microsoft.com downloads.  This will show you the kind of
markup required.  If you want to, you can just comment out the lines in the
generated proxy that define the data interface for your service, add a
reference to the assembly created by XsdObjectGen to the project, add a
Using/Imports statement at the top of the proxy code file, and compile.  
This should do the trick.

Hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "Steve Lutz" <slutz@nospam.comcast.net>
Subject: Interesting Problem With WebService results and Repeater Control
Date: Sat, 4 Dec 2004 08:35:03 -0500
Lines: 41
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.181
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
Message-ID: <##bwWbg2EHA.1188@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: nat153.infonautics.com 208.37.113.153
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXS01.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08
.phx.gbl!tk2msftngp13.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7853
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have written a web service to provide some back-end functionality to a Web
Site.  The web service returns lists of items.
If I use the webservice via a browser, it works fine and returns the results
in XML.
I then created the proxy for the Web Service in VS.NET. I can call the
webmethod fine and get an array of Items. (Although it's a local class to
the WebSite).

When I attempt to have a repeater control list the reults in a web form, I
get an error that the class Item does not contain a property called "Name".
I'm not sure where to go from here aside from attempting to convert the Item
array into something else manually.

---------
Quick Code Example

[Web Method]
public Item[] GetItems(string CategoryID)
{
   return ItemList(CategoryID);        // Helper function that constructs
the array
}

Class Item
{
   private string _name;
   Public Name
   {
       Get { return _name;};
       Set { _name = value}
   }

}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.