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):
And here is the GridAdoNetDataService.cs:
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.
}