This is a migrated thread and some comments may be shown as answers.

RadGrid bound to web service without Linq

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alfred
Top achievements
Rank 1
Alfred asked on 22 Sep 2010, 06:09 PM

I want to bind a RadGrid to a web service without using Linq. In all examples I can find, the web service has to return a List(Of MyObject); I've tried this, and it works great. However, the table I'm binding to may at runtime have additional columns, or columns may have different data type, so I can't use a static MyObject class to represent the table at compile time. I also don't know at compile time which columns need to be displayed in the grid. I would like to bind to a web service for performance reasons.

I've tried having the web service method return a DataView, and cast it a lot of different ways, but it's not working. How would I write the GetData / GetDataAndCount method of the web service to return the data from a DataView or other non-linq data source?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 28 Sep 2010, 12:02 PM
Hi Alfred,

When you use the client side data binding you could not change the RadGrid definition dynamically. The client side binding does not support modifying the columns collection of the RadGrid dynamically.
In order to bind the RadGrid to different columns and change it structure dynamically you need to use the approach described in the following online documentation article:
http://www.telerik.com/help/aspnet-ajax/grdchanginggridstructuredynamically.html

Also all online demos use List as returned type because it is serialized properly. The DataTable, DataRow, DataView, and DataViewManager objects cannot be serialized and cannot be returned from an XML Web service.To achieve the desired functionality and bind the RadGrid to object different than List you could try implementing a custom javascript converter and register it to the JavascriptSerializer. Otherwise  you will receive the exception because all data tables contains circular references and the following error will occur if you try to use it as a returned type of web service method:
A circular reference was detected with serializing an object of type System.Globalization.Cutureinfo' : at System.Web.Script.Serizlization.JavaScriptSerializer.SerializeValueinternal.
To view this you could try requesting the web service method which returns DataSet or DataTable
.
Additionally you could check out the following online articles which elaborate on the same matter:
http://support.microsoft.com/kb/306134

All the best,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alfred
Top achievements
Rank 1
answered on 30 Sep 2010, 07:25 PM
I received a great answer to this on stackoverflow:
http://stackoverflow.com/questions/3771748/telerik-radgrid-bound-to-web-service-without-linq
which solved my problem perfectly.
Tags
Grid
Asked by
Alfred
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Alfred
Top achievements
Rank 1
Share this question
or