RadGrid binding with web service

2 posts, 0 answers
  1. Piyush Bhatt
    Piyush Bhatt avatar
    166 posts
    Member since:
    Nov 2007

    Posted 09 Jan 2014 Link to this post

    I have a sample program and trying to use the declarative binding using WCF service. It does not give error but only shows empty grid. it also shows the count but not the data. Data service returns data JSON data as well that I can see via browser developer tools.
                    <ClientEvents OnDataBindingFailed="onError" />
                    <DataBinding Location="DataService.svc"

    Here is the service interface:
        public interface IDataService
            [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
            StateResult GetStatesForGrid(int startRowIndex, int maximumRows, string sortExpression, string filterExpression);

    Here is the service code (this is just sample code, goal is not to actually try filtering paging etc, just to send data and see if it binds):

        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
        public class DataService : IDataService
            public StateResult GetStatesForGrid(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
                StateResult result = new StateResult();
                List<State> states = GetDataFromDb();
                result.Count = states.Count;
                result.Data = states;

                return result;

    If I use the ASMX service and call the same service method - it works fine. But not for WCF.

    Another issue is, I tried calling the same method via PageMethod and use the .aspx page and method name in the declarative clientsettings - but that gives error that 'startIndex' not found.
  2. Marin
    Marin avatar
    1057 posts

    Posted 14 Jan 2014 Link to this post


    The client-side binding configuration that you posted looks correct. Only thing is you do not need to set  DataPropertyName when binding to WCF services. Other than that the method should be called and return data. An online working example is also available here:
    You can use it as a starting point and modify it according to your needs.
    Using page methods is not necessary here, because WCF biding should also work fine if you follow the approach in the demo.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top