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

RadGrid bound to ADO.NET Data Service - Parameters

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kristjan
Top achievements
Rank 1
Kristjan asked on 05 Sep 2014, 10:06 AM
Hi
I'm new to Telerik RadGrid and it's databinding. I'm trying to use the ADO.NET Data Service binding but I need to pass parameter. I'm using the sample code but I need to modify it a little bit.

In a perfect world I would add an ID="dbAdoDataService" and runat="server" to the <DataBinding .... > and then in code behind I could use something like dbAdoDataService.SelectParameter = Convert.ToInt32(Request.QueryString["ProductID"]);. But it's not possible to add runat="server" or add an ID to the DataBinding so what can I do to select the rows I want at runtime? And I'm not sure how to modify the GridAdoNetDataService.cs. Please help me I'm stuck.  (Hope you understand my bad english).

Here is the samplecode from Telerik support site:

This is the binding code (Default.aspx):

1.<ClientSettings>
2.    <DataBinding Location="GridAdoNetDataService.svc" SelectCountMethod="GetCount">
3.        <DataService TableName="ReadOnlyProducts" />
4.    </DataBinding>
5.</ClientSettings>

And here is the GridAdoNetDataService.cs:

01.public class GridAdoNetDataService : DataService<NorthwindEntities>
02.{  
03.    public static void InitializeService(IDataServiceConfiguration config)
04.    {      
05.         config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
06.         config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
07.    }
08.  
09.    [WebGet]
10.    public int GetCount(string where)
11.    {
12.        return String.IsNullOrEmpty(where) ? CurrentDataSource.ReadOnlyProducts.Count() :
13.            CurrentDataSource.ReadOnlyProducts.Where(where).Count();
14.    }
15.  
16.}

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 10 Sep 2014, 05:59 AM
Hi Kristjan,

I am afraid you could not pass additional parameter to the service when using the built-in Client DataBinding. Nevertheless you could use the ClientDataSource control where such scenario is possible. Please check out the following live example and the related documents for more information.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Kristjan
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or