Click here to Skip to main content
15,918,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Actually i am using the listview in wcf services to store the data. from that i want to get the data to aspx.cs page is it possible or is there any way to get the data from wcf to aspx.cs page
Posted

1 solution

Add web reference in your client application, and then consume the service.

For instance, assume that your web reference is called MyWebService and your service you want to invoke is DataServiceClient, as seen below. You can return the result in your preference container, in this example, I use a DataTable.

C#
public static DataTable GetData(int operationID)
        {
            DataTable dtResult;

            MyWebService.DataServiceClient client = new MyWebService.DataServiceClient();

            dtResult = client.GetData(operationID);

            client.Close();

            return dtResult;
        }
 
Share this answer
 
Comments
ntitish 2-May-13 4:08am    
sir thanks for ur reply but instead of dataset or datatable i want to use list or arrays is it possible...if possible,can u give me a sample code or any example bec i am facing error while using list.....
Balimusi 2-May-13 9:22am    
Yes, of course is possible. Do something like this:
private ArrayList getItemsFromListView()
{
MyWebService.DataServiceClient client = new MyWebService.DataServiceClient();
//Get your ListView listViewFromService;
ListView listView = client.ListViewFromService();
ArrayList arrayList = new ArrayList();

foreach (ListViewItem itemRow in this.listView.Items)
{

for (int i = 0; i < itemRow.SubItems.Count; i++)
{
arrayList .Add(itemRow.SubItems[i].Text);

}
}
return arrayList ;
}
Balimusi 2-May-13 9:25am    
Btw, I have an article on WCF service, there is an example using a class properties to hold the data and return a generic List<>. http://www.codeproject.com/Articles/581273/WCF-4-5-Services-Development-with-Entity-Framework

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900