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

[Solved] RadGrid Binding to a ADO.Net Data Service

2 Answers 233 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 19 Oct 2009, 05:22 PM

Ok.. after reading the documentation on binding ado.net data service every example seems reflect everything im doing but its still not working. Here is what i have

Service.svc code

 

 

   Public Shared Sub InitializeService(ByVal config As IDataServiceConfiguration)  
        config.SetEntitySetAccessRule("*", EntitySetRights.AllRead)  
        config.SetServiceOperationAccessRule("*", ServiceOperationRights.All)  
    End Sub 

 

 

 

 

 

 

 

  <WebGet()> _  
    Public Function GetSessions() As IQueryable(Of Session)  
        Return (From Sessions In Me.CurrentDataSource.Session _  
                                             Select Sessions)  
    End Function 
 
    <WebGet()> _  
    Public Function GetCount(ByVal where As StringAs Integer 
        Return If([String].IsNullOrEmpty(where), CurrentDataSource.Session.Count(), CurrentDataSource.Session.Where(where).Count())  
    End Function 
 


This service works fine..

Here is my web page code

 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">  
        </telerik:RadScriptManager> 
      
    </div> 
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">  
        <telerik:RadGrid ID="RadGrid1" runat="server"   
            GridLines="None" AutoGenerateColumns="False">  
              
             <MasterTableView> 
                  
             </MasterTableView> 
             <ClientSettings> 
                 <DataBinding Location="http://localhost:1687/BCSS.svc/"   
                      SelectMethod="GetSessions" 
                      SelectCountMethod="GetCount" > 
                     <DataService TableName="Session" /> 
                 </DataBinding> 
             </ClientSettings> 
 
        </telerik:RadGrid> 
    </telerik:RadAjaxPanel> 
    </form> 
</body> 
</html> 
 

When i run the page it gives me the following error "Cannot find any bindable properties in an item from the datasource "
All of the examples mention i have to a Location,Selectmethod,Selectcountmethod when calling a data service. What am i miss here?

However if i comment out the clientside setting and put in a serverside code on the page load like this it works
 Dim WS As New BCSSEntities(New Uri("http://localhost:1687/BCSS.svc/", UriKind.Absolute))  
 
        Dim query = From Session In WS.Session _  
        Select Session  
 
        Me.RadGrid1.DataSource = query  
        Me.RadGrid1.DataBind() 


Please advise!!

2 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 20 Oct 2009, 03:21 PM
Anyone monitoring these forums????
0
Rosen
Telerik team
answered on 22 Oct 2009, 10:39 AM
Hello Michael,

In order client-side databinding to work you should declare columns for the RadGrid. You may refer to this online demo for an example.

Kind regards,
Rosen
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
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or