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

[Solved] Declarative/programmtic binding with Web Service (asmx) w/Session and IDictionary

1 Answer 334 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cranialstrain
Top achievements
Rank 1
Cranialstrain asked on 09 Dec 2009, 04:00 PM
I wonder if someone could please help with the following issue I have. This is our last-roll-of-the-dice with Telerik components before we decide to ditch them in favour of our own implementations, everything is just too difficult or example code out-of-date.

Problem
We have decided to move one of our RadGrid test-cases to client-side binding using a web service. Initially starting with [WebMethod]'s in the aspx page we moved to a ASMX service to we could enforce session and reduce the data calls (as detailed in the Telerik demos here); it says:

To optimize even more the grid client-side data binding you can get both data and total items count in a single request. Example:   
...  
    [WebMethod(EnableSession = true)]  
    public Dictionary<stringobject> GetDataAndCount(int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression)  
    {  
        Dictionary<stringobject> data = new Dictionary<stringobject>();  
 
        data.Add("Data", GetData(startRowIndex, maximumRows, sortExpression, filterExpression));  
        data.Add("Count", (int)Session["Count"]);  
 
        return data;  
    }  
...  
 

Simple huh!? No, as web services apparently no longer support IDictionary:

The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutralPublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=2.0.0.0, Culture=neutralPublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.  

Ultimate goal
What I'm trying to (ideally) achieve here is webservice that returns data two sets of data for (a) mastertableview and (b) detailtable as one call without making secondary calls to get the data count (especially as it will relate to the VirtualItemCount). If this isn't possible I'm happy to make two seperate calls, one for the mastertableview and one for the detail view, but I do not want to make a second call for 'record count' on each of the those calls (thus making 4).

Is this possible or are we better doing something else? Your urgent thoughts on this much appreciated!

Ian

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 10 Dec 2009, 05:19 PM
Hello Cranialstrain,

Is it possible that you get this error when you trigger a direct call to your web service and attempt to retrieve the result from it? If so, you may consider defining your own object (custom class) with strongly-typed properties and specify that class as return type of the webservice. Thus you should be able to avoid the exception.

Note that using a generic list of Dictionary objects is handled automatically by RadGrid as illustrated on this online demo:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/declarativedatabinding/defaultcs.aspx

Client-side binding with hierarchy is not supported out-of-the-box, however you can use one of the solution presented in this blog post on our site. Note that you will need to handle the client-binding manually and build your implementation (with the custom class suggested in the previous paragraph) thus to return the data and count of master and detail table items in one or two calls.

Best regards,
Sebastian
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Cranialstrain
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or