Web Service Data Source not connecting

4 posts, 0 answers
  1. Mary
    Mary avatar
    20 posts
    Member since:
    Nov 2017

    Posted 24 Apr 2018 Link to this post

    Good afternoon,

    I am trying to connect a RadClientDataSource to a web Service but it is not getting called (I know because i am tracing the sql database that it uses and I have tried with breakpoints). At present the code is:

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageSingleMenu.Master" AutoEventWireup="true" CodeFile="Grid.aspx.cs" Inherits="Grid" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
        <link href="styles/grid.css" rel="stylesheet" />
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
           <telerik:RadGrid RenderMode="Lightweight" ID="dgSessions" runat="server" AutoGenerateColumns="false"  AllowSorting="true"
                  EnableHeaderContextMenu="true"  ClientDataSourceID="RadClientDataSource1" 
              AllowMultiRowSelection="false"  >
                <MasterTableView Width="100%" ClientDataKeyNames="SessionKey" DataKeyNames="SessionKey" CommandItemDisplay="None">
                        <telerik:GridBoundColumn UniqueName="HorseName" HeaderText="Horse" DataField="HorseName" ReadOnly="True">
                    <telerik:GridBoundColumn UniqueName="BT200" HeaderText="BT200" DataField="BT200" ReadOnly="True">

        <telerik:RadClientDataSource ID="RadClientDataSource1" runat="server">
                    <WebServiceDataSourceSettings ServiceType="OData" >
                        <Select Url="http://localhost:49833/ETSession.svc/GetSessions" DataType="JSON" />
                    <Model ID="SessionKey">
                        <telerik:ClientDataSourceModelField FieldName="SessionKey" />
                        <telerik:ClientDataSourceModelField FieldName="HorseName" DataType="String" />
                        <telerik:ClientDataSourceModelField FieldName="BT200" />

    I have tried with a remote web service, also with the web service code file in the same project as the page, but to no avail.

    I have also tried the follwing snippet:

    <WebServiceDataSourceSettings ServiceType="OData" BaseUrl="http://localhost:49833/ETSession.svc/" >
                        <Select Url="GetSessions" DataType="JSON" />

    This results in GetSessions giving a Not Found indicator (green squigly line under the name) - that occurs in all three scenarios (remote, local or in-place).

    The service works as i have tested it from another project.

    Using VS2010 and .Net 4


    Would welcome any thoughts.


  2. Marin Bratanov
    Marin Bratanov avatar
    5809 posts

    Posted 26 Apr 2018 Link to this post

    Hello Mary,

    Can you try the following changes to mimic our online demo (https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-data-source-binding/defaultcs.aspx):

    • make the base URL relative so the browser will fill in the port and protocol and the path to the web application, in case there is a mismatch there
    • remove the ServieType=OData setting especially if the response is JSON (which is the most common scenario)

    The idea is to have this:

    <WebServiceDataSourceSettings BaseUrl="ETSession.svc/">
        <Select Url="GetSessions" DataType="JSON" />

    The next thing to do is to monitor the browser console (or use a tool like Fiddler) to examine the network traffic to see what is going on with the request. For example, it may be getting blocked by a firewall/anitvirus, or IIS may be throwing an error before reaching your managed code. The following blog shows how to do that, among other things: https://www.telerik.com/blogs/improve-your-debugging-skills-with-chrome-devtools#inspect-network-requests.

    That said, the grid can also read data from various services without a RadClientDataSource, so you may want to take a look at that as well: https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/declarative/defaultcs.aspx.

    The final option I can suggest is that you fetch the data with your own code (like jQuery.get()) and provide it to the grid as a simple array of objects: https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/programmatic/defaultcs.aspx.

    I hope this information helps you either troubleshoot the current setup, or implement another one that fits your needs. If not, I will need you to open a ticket and send us a small runnable example that showcases the problem so we can investigate.

    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Mary
    Mary avatar
    20 posts
    Member since:
    Nov 2017

    Posted 06 May 2018 in reply to Marin Bratanov Link to this post

    Thanks Marin,

    I have changed tack now - my goal is to have json data retrieved then stored locally and turned into a datasource for a rad grid and rad chart. I can get the json string easily in client script (java script) but am unable to set the datasource of the rad grid (the first thing I am trying).

    The examples are for the kendo grid and I do not think they work in this case. My latest attempt is:

    var grid = $find("<%= dgSessions.ClientID %>");
                    var dataSource = new kendo.data.DataSource({ data: res });
                    var tableView = grid.get_masterTableView();

    I know the res data is good, well formed json as I can see it with an alert - but how do I make it the data source for the grid?

  4. Mary
    Mary avatar
    20 posts
    Member since:
    Nov 2017

    Posted 06 May 2018 in reply to Mary Link to this post

    GOT IT!!!!

    function CallSuccess(res) {
                try {
                    var grid = $find("<%= dgSessions.ClientID %>");
                    var tableView = grid.get_masterTableView();


    where res is the JSON string

Back to Top