Hello.
In order to familiarize with the RadGrid component, I have created a small application whose grid is populated by a web service.
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
DataType
=
"System.Int32"
/>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
DataType
=
"System.String"
/>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
DataBinding
Location
=
"WebService.cs"
SelectMethod
=
"RetrieveRows"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
</
form
>
</
body
>
</
html
>
WebService.cs:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.ServiceModel;
using
Telerik.Web.UI;
namespace
WebApplication1
{
[ServiceContract(Namespace =
""
)]
[System.Web.Script.Services.ScriptService]
public
class
WebService
{
public
WebService ()
{
}
[OperationContract]
public
Dictionary<
string
,
object
> RetrieveRows(
int
startRowIndex,
int
maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression)
{
Dictionary<
string
,
object
> dictionary =
new
Dictionary<
string
,
object
>();
dictionary.Add(
"Data"
,
new
[] {
new
{ ID = 1234, Name =
"Test"
}});
dictionary.Add(
"Count"
, 1);
return
dictionary;
}
}
}
The compilation was successful, but the following error message was displayed at runtime by the built-in script debugger of Internet Explorer:
Line: 6563
Error: Sys.ArgumentException: Cannot deserialize empty string.
Parameter name: data
I would appreciate whether some assistance could be provided to solve this problem.
Last but not least:
a) I was wondering how the application could be implemented using a server-side binding solution.
b) What is Telerik's recommendation in regard to client versus server-side binding implementations using a web service?
Thank you in advance.
Paulo