Thursday, May 24, 2012

JSON Web Service - Asp.net DataTable

I found a great article on how to pull ADO.Net DataTable in an XML web service and return JSON table.

http://williamsportwebdeveloper.com/cgi/wp/?p=494

This is a VERY good read - easy to understand.  This is a good place to start when first pulling data from table... for JSON to use.

And if you want to pull JSON data from code behind, it is easy to.. If the data is only used on one page, why expose a web service api to it...

http://dotnet-treasure.blogspot.in/2011/03/bind-drop-down-list-using-json.html

Notice how it is decorated with [ScriptService]
---------------

After doing this, you may consider enhancing.

You can make an array of serializable objects... instead of a Jagged array.   Just apply the JavaScriptSerializer to it. 
http://www.codeproject.com/Articles/1789/Object-Serialization-using-C


------------------------
Putting it together...

If you are binding a Linq Query to Kendo UI, (using JSON) here is an awesome resource:

http://www.kendoui.com/blogs/teamblog/posts/12-05-11/hello_services_webapi_rest_json_and_ajax.aspx

It tells all sorts of goodies - like what references to make... etc.  It is MVC, if you use that.  If not, you have to adjust somewhat.


No comments:

Post a Comment