In this article we will see how to send a List<> from an ASP.NET Webserivce and consume a List<> in our application.
In this article we will see how to send a List<> from an ASP.NET Webserivce and consume a List<> in our application.I am providing a simple procedure with snapshots for a good understanding and for you to use in your projects.Let's create our webservice first for sending a List.Step 1: Open Visual Studio then select "File" -> "New" -> "Project..." then provide the project a name.Step 2: Let us add a class with the name Mobiledetails.cs.Inside this class we will do Get { } and Set { } Parameters. Step 3: Also create another class inside Mobiledetails.cs with the name Mobiledetailslist. Which contains List<> of Mobiledetails ( List<Mobiledetails> ).You can see the image below for reference.
In this webmethod I have created an object of class Mobiledetails and accessed its properties for assigning a value.After assiging a value to the properties I created a List <Mobiledetails> object and added properties to the List. And finally returing a list.Now we have completed the part of sending a List. Just run your application now.You will see the same screen that is given below.Now just copy this URL.:
http://localhost:2157/Service1.asmx
Namespace
In this code I created an object of the webservice that we added.
I used a loop for getting the data from the List and a StringBuilder for displaying the formatted data.The last thing is to add a Literal for displaying this list.After completing, just run the application and check it.Here is the output:Now we have successfully transferred this list.
Pro WPF: Windows Presentation Foundation in .NET 3.0