如何一次保存所有gridview行使用JQuery而不回发? [英] How to save all rows of gridview at a time Using JQuery without postback?

查看:55
本文介绍了如何一次保存所有gridview行使用JQuery而不回发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,我希望一次保存所有行,我可以制作gridview数据源的数据表并将其传递给SP

I have a gridview from it i want save all rows at a time ,Can I make a datatabel of gridview datasource and pass it to SP

推荐答案

有可能是您问题的多种解决方案;这里是我过去使用的一个



如果你只想使用jQuery,你必须创建可访问的端点,它将发送和接收JSON数据。一旦你有了这个,你可以将gridview中的数据作为一个JSON对象数组读取并发送到



1.创建端点以发送和接收在JSON数据中,您可以使用webHttp端点行为创建WCF服务,以便您可以从javascript代理访问它。



要检查是否创建了js代理,可以使用/ js例如http://localhost/crud/servuce.svc/js键入WCF服务URL。 notice / js最后这将启用下载javascript代理,并使您能够编写代码以在javascript中调用WCF函数。 / js将生成缩小的生产就绪代理如果要在调试中使用,则可以使用/ jsdebug而不是/ js



2.读取所有可用的记录使用jquery函数/循环等网格并将数据推送到数组中。



3.调用javascript客户端函数并将创建的数组与数据一起传递给WCF方法可以通过javascript函数访问。



4.在WCF服务内部调用服务器端的函数后,您可以使用JavaScriptSerializer对接收到的数组进行反序列化,以获得您从javascript客户端传递的集合回集合。



5.一旦有了集合,您就可以操作它并将其作为DataTable发送到存储过程



希望有所帮助,

谢谢
There could be multiple solutions to your problem; here is one which I have used in the past

If you only want to use the jQuery you will have to create accessible endpoint which will send and receive JSON data. Once you have that in place, you can read the data in the gridview as an array of JSON objects and send it across

1. To create endpoint to send and receive the JSON data, you can create a WCF service with webHttp endpoint behavior so that you can access it from javascript proxy.

To check whether js proxy is getting created, you can type the WCF Service url with /js e.g http://localhost/crud/servuce.svc/js. notice /js at the end this will enable to download javascript proxy and will enable you to write the code to call WCF function within the javascript. /js will generate the minified production ready proxy if you want to use in debugging you can use /jsdebug instead of /js

2. Read all the records available in a grid using jquery functions/loop etc. and push the data into an array.

3. Invoke the javascript client function and pass the created array with data to the WCF method accessible as javascript function.

4. Once you invoke the function on the server side inside the WCF service you can de-serialize the received array using JavaScriptSerializer so to get the collection back collection you passed from javascript client.

5. Once you have the collection you can manipulate it and send it as a DataTable to the stored procedure

Hope that helps,
Thanks


这篇关于如何一次保存所有gridview行使用JQuery而不回发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆