This is a migrated thread and some comments may be shown as answers.

bind a listview to an ASP.Net .asmx web service using KendoUI mobile

1 Answer 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bavya
Top achievements
Rank 1
Bavya asked on 17 Oct 2012, 10:58 AM
Hello,

I was trying to bind a listview to an ASP.Net .asmx web service using KendoUI mobile. I referred the following link to achieve this. But it’s not working for me.
http://www.kendoui.com/forums/framework/data-source/consuming-a-net-json-web-service.aspx

Pasting my code snippet for more help. Please let me know whether I am in right direction or what’s wrong with my code.  It’s urgent, please help me.

index.html:-
<!DOCTYPE html>
<html>
<head>
    <title></title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
    <meta charset="utf-8">
    <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
    <script src="js/jquery.min.js"></script>
    <script src="js/kendo.mobile.min.js"></script>
    <script src="js/console.js"></script>
    <link href="styles/kendo.common.min.css" rel="stylesheet" />
    <link href="styles/kendo.mobile.all.min.css" rel="stylesheet" />
</head>
<body>
    <a href="../index.html">Back</a>
    <div data-role="view" id="flat" data-init="mobileListViewDataBindInitFlat" data-title="ListView" data-layout="databinding">
    <ul id="flat-listview"></ul>
</div>
<script>
var flatData = new kendo.data.DataSource({
   transport: {
                        read: {
                            contentType: "application/json",
                            type: "POST",
                            url: "http://myservice/TestService.asmx/GetCustomerData",
                           data: {
                                    q: "html5"
                                 }
                              }
              }
});
    function mobileListViewDataBindInitFlat() {
        $("#flat-listview").kendoMobileListView({ dataSource: flatData });
    }
</script>
    <script>
        window.kendoMobileApplication = new kendo.mobile.Application(document.body);
    </script>
</body>
</html>

TestService.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using Northwind_newModel;
 
[ScriptService]
public class TestService : System.Web.Services.WebService {
    [WebMethod]
    public List<CustomerModel> GetCustomerData()
    {
        using (var northwind = new Northwind_newEntities1())
        {
            return northwind.Customers
                 .Select(p => new CustomerModel
                {
                    CompanyName = p.CompanyName
                }).Take(5).ToList();
         }
    }
}

Thanks.

1 Answer, 1 is accepted

Sort by
0
Bavya
Top achievements
Rank 1
answered on 30 Oct 2012, 11:21 AM
Hello Team,

Please help me, its urgent and I got stuck here.

thanks
Tags
General Discussions
Asked by
Bavya
Top achievements
Rank 1
Answers by
Bavya
Top achievements
Rank 1
Share this question
or