I have a sample program and trying to use the declarative binding using WCF service. It does not give error but only shows empty grid. it also shows the count but not the data. Data service returns data JSON data as well that I can see via browser developer tools.
<ClientSettings>
<ClientEvents OnDataBindingFailed="onError" />
<DataBinding Location="DataService.svc"
SelectMethod="GetStatesForGrid"
DataPropertyName="Data"
FilterParameterType="Linq"
SortParameterType="Linq"></DataBinding>
</ClientSettings>
Here is the service interface:
[ServiceKnownType(typeof(State))]
[ServiceContract]
public interface IDataService
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
StateResult GetStatesForGrid(int startRowIndex, int maximumRows, string sortExpression, string filterExpression);
Here is the service code (this is just sample code, goal is not to actually try filtering paging etc, just to send data and see if it binds):
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class DataService : IDataService
{
public StateResult GetStatesForGrid(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
{
StateResult result = new StateResult();
List<State> states = GetDataFromDb();
result.Count = states.Count;
result.Data = states;
return result;
}
If I use the ASMX service and call the same service method - it works fine. But not for WCF.
Another issue is, I tried calling the same method via PageMethod and use the .aspx page and method name in the declarative clientsettings - but that gives error that 'startIndex' not found.
<ClientSettings>
<ClientEvents OnDataBindingFailed="onError" />
<DataBinding Location="DataService.svc"
SelectMethod="GetStatesForGrid"
DataPropertyName="Data"
FilterParameterType="Linq"
SortParameterType="Linq"></DataBinding>
</ClientSettings>
Here is the service interface:
[ServiceContract]
public interface IDataService
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
StateResult GetStatesForGrid(int startRowIndex, int maximumRows, string sortExpression, string filterExpression);
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class DataService : IDataService
{
public StateResult GetStatesForGrid(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
{
StateResult result = new StateResult();
List<State> states = GetDataFromDb();
result.Count = states.Count;
result.Data = states;
return result;
}
Another issue is, I tried calling the same method via PageMethod and use the .aspx page and method name in the declarative clientsettings - but that gives error that 'startIndex' not found.