- Home
- Forum
- ASP.NET MVC (Classic)
- Sample for Databinding to a webservice
Sample for Databinding to a webservice
[WebMethod]
public virtual GridWebService Index(WebServiceParams webParams)
{
IEnumerable<License> licenseList = GetItems().ToList();
return licenseList.GridWebServiceAction<License>(webParams);
}
Hi Jeremy,
Thanks for using Syncfusion products.
We suspect that you have used the code IEnumerable<License>
in your cshtml page. Please remove the specified code from your cshtml page to
avoid your reported issue.
Please refer our online documentation
link for further reference.
http://help.syncfusion.com/ug/asp.net%20mvc/grid/default.htm#!documents/webservicedatabindin.htm
Please let us know if you have need further
assistance.
Regards,
P.SarathKumar.
[InvalidOperationException: Cannot serialize member 'Syncfusion.Mvc.Grid.GridWebService.Data' of type 'System.Collections.IEnumerable', see inner exception for more details.]
System.Xml.Serialization.StructModel.CheckSupportedMember(TypeDesc typeDesc, MemberInfo member, Type type) +5531266
System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo) +125
System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo) +89
System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter) +247
System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter) +378
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter) +1734
[InvalidOperationException: There was an error reflecting type 'Syncfusion.Mvc.Grid.GridWebService'.]
Hi Jeremy,
We regret for the inconvenience caused.
We suggest you to refer the below Web
service asmx code snippets, cshtml page code snippets for your reference.
[Orders.asmx.cs]
namespace
Syncfusion.Mvc.Grid.Models
{
using
System.ComponentModel;
using
System.Linq;
using
System.Web.Script.Services;
using
System.Web.Services;
using
MVCSampleBrowser.Models;
using
Syncfusion.Mvc.Grid;
using
System.Collections;
using
System.Xml.Serialization;
using
System.Runtime.Serialization;
using
System.Collections.Generic;
using
System.ServiceModel.Web;
[WebService(Namespace
= "http://tempuri.org/")]
[WebServiceBinding(ConformsTo
= WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[ScriptService]
public
class OrdersAsmx : System.Web.Services.WebService
{
[WebMethod]
public
GridWebService RenderOrders(WebServiceParams webParams)
{
IEnumerable
data = new NorthwindDataContext().OrdersViews.Take(100).ToList();
return
data.GridWebServiceAction<OrdersView>(webParams);
}
}
}
[Asmx.cshtml]
@(Html.Syncfusion().Grid<OrdersView>("Grid1")
.Caption("Orders")
.WebService(Url.Content("~/Models/Orders.asmx/RenderOrders"))
.Column(column
=>
{
column.Add(p
=> p.OrderID).HeaderText("Order ID").TextAlign(TextAlignment.Right).Width(100);
column.Add(p
=> p.EmployeeID).HeaderText("Employee
ID").TextAlign(TextAlignment.Right).Width(115);
column.Add(p
=> p.ShipAddress).HeaderText("Ship Address");
column.Add(p
=> p.ShipCity).HeaderText("Ship City").Width(150);
column.Add(p
=> p.ShipCountry).HeaderText("Ship Country").Width(170);
})
.EnablePaging().PageSettings(p
=> p.PageCount(5))
.EnableSorting()
.EnableGrouping().EnableFiltering()
.AutoFormat(Skins.Marble))
Please let us know if you need further
assistance.
Regards,
P.Sarathkumar.
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class LicenseService : System.Web.Services.WebService
{
class test
{
public int prop { get; set; }
}
[WebMethod]
public GridWebService Get(WebServiceParams webParams)
{
var testList = new List<test>();
return testList.GridWebServiceAction<test>(webParams);
}
}
Hi Jeremy,
We are sorry for inconvenience caused. We are unable to reproduce the issue. We have prepared a simple working sample and the same can be downloaded from the following links.
Could you please try the below sample and get back to us whether you are able to reproduce the issue? If not, could you please give more information or by reproducing the issue in the above sample so that we could sort out the issue and provide you with solution. The information provided would be of great help in resolving the issue.
Sample :
Please let us know if you need any further assistance.
Regards,
Rakesh D
WebServiceDemo_3cab800a.zip
- 6 Replies
- 3 Participants
-
JB Jeremy Branham
- Nov 13, 2013 04:25 AM UTC
- Dec 18, 2013 10:14 AM UTC