开发者

Passing gridview rows to WebMethod

I want to send Gridview rows to WebMethod. What is the best way to send the collection from javascript t开发者_如何学Pythono Code behind as a parameter?


I had to do something similar to what you're asking recently. I don't do any javascript normally, but this is the steps I took:

Create a web method that returns a collection of grid view rows. Just create a dummy web method that creates an IList containing two rows, populate the rows if you fancy. Then return the collection.

Next, using your favourite browsers' development tools, debug the return call and examine the result. Bearing in mind I don't do js, but when I tried the above I found that the result was what I would describe as a generic array containing an anonymous type which housed the properties/columns of the row.

Once you understand what those objects look like, you can create them...

I know it's a vague answer (sorry), but that's the method I used to learn this for myself and it worked.


With plain javascript, u cannot send objects. But u can use json-jQuery, u can. U will have to construct the gridview as json object and u can send it as a input to the web-method. Creating json object is just like creating the javascript object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜