in Default.aspx
<script type="text/javascript">
var dataSource = new kendo.data.DataSource(
{
transport: {
read: {
contentType: "application/json; charset=utf-8",
type: "POST",
dataType: "json",
url: "http://localhost:1249/KendoUI2nd/WebService.asmx/LoadData"
}
},
pageSize: 10,
schema: {
model: {
fields: {
Pkid_Emp: { type: "number" },
fkid_Dept: { type: "string" },
txt_Name: { type: "string" },
txt_Address: { type: "string" },
txt_Phone: { type: "string" },
txt_Salary: { type: "string" }
}
}
}
});
alert(dataSource);
$(document).ready(function () {
$("#myGrid").kendoGrid({
dataSource: dataSource,
height: 250,
columns: [
{ field: "Pkid_Emp", title: "Pkid_Emp" },
{ field: "fkid_Dept", title: "fkid_Dept" },
{ field: "txt_Name", title: "txt_Name" },
{ field: "txt_Address", title: "txt_Address" },
{ field: "txt_Phone", title: "txt_Phone" },
{ field: "txt_Salary", title: "txt_Salary" }
]
});
});
</script>
<div>
<div id="myGrid">
</div>
</div>
in Webservice.cs
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string LoadData()
{
MyDataClassesDataContext MyDB = new MyDataClassesDataContext();
var sharedDataSource1 = from x in MyDB.Emps
select x;
var serializer = new JavaScriptSerializer();
return serializer.Serialize(sharedDataSource1);
}
when is called webservice i get JSON Data . still my grid is empty . Please Help me ...
Thanks i read ur example n i implement read() into my project
but it showing me
System.NotSupportedException: Cannot serialize interface System.Collections.Generic.IEnumerable`1[[EmployeeClass, App_Code.7o30vskr, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].
at System.Xml.Serialization.TypeDesc.CheckSupported()
at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
at System.Xml.Serialization.ModelScope.GetTypeModel(Type type, Boolean directReference)
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defaultNamespace)
at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
I Dont Know why ????
Please Help Me ...