views:

2062

answers:

4

i know this is an age old question, but this is my scenario

This is in C# 2.0

Have a windows application which has a datagridview control. This needs to be populates by making a webservice call.

I want to achive the same functionality on the data if i were to use a direct connection and if i were using datasets, namely like paging and applying filters to returned data. i know returning datasets is a bad idea and am looking to find a good solution.

+1  A: 

I might look at ADO.NET Data Services, aka Astoria, in VS2008 SP1.

This allows you to expose data over a web-service (WCF exposing ATOM, IIRC) - but you don't need to know all these details: the tooling worries about that for you: you just get regular IQueryable<T> sources on a data-context (not quite the same as the LINQ-to-SQL data-context, but same concept).

The good thing here is that a LINQ query (such as filtering (Where), paging (Skip/Take) etc) can get composed all the way from the client, through the web-service, and down to the LINQ-enabled data store (LINQ-to-SQL or Entity Framework, etc). So only the right data comes over the wire: if you ask for the first 10 rows (of 20000) ordered by Name, then that is what you get: 10 rows out of the database; 10 rows over the wire, no messing.

Marc Gravell
Marc, due to limitations of business, I cannot use VS2008 and am limited to VS2005
darn; sorry about that - it would seem a good fit.
Marc Gravell
+1  A: 

Write a custom class (MyDataItem) that'll hold your data. Then you can pass a List<MyDataItem> or some collection of MyDataItem and bind to your grid.

Paging, filtering, etc. would need to be implemented by you.

Kon
+1  A: 

There is no way to get the binding behavior you automatically get with a DataSet if you are going through a Web Services data layer. You would have to create your own proxy class that supports all the databinding functions and persists them through your web service calls. Depending on your application's environment, you may want to batch up modifications to avoid excess round trips to the web services.

Jeff Kotula
A: 

fallen888 has it right - you will need to create a collection class of List or a DataTable, fill it with the output from the webservice data stream, and handle paging and filtering yourself yourself.

David Robbins