且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Gridview行由javascript添加。

更新时间:2023-12-06 17:11:04

您的动态添加行而不回发的请求是只是自相矛盾。你用Javascript做什么(以及使用jQuery以最方便的方式完成)只发生在客户端。从ASP.NET应用程序的角度来看,它是服务器端(代码隐藏),您新行根本就不存在。那么,你会期待什么?



在从客户端发送一些HTTP请求之前,服务器端没有任何事情发生。其中一种方法是直接使用Ajax:

http:// en。 wikipedia.org/wiki/Ajax_%28programming%29 [ ^ ],

http://www.xul.fr/ en-xml-ajax.html [ ^ ]。



使用Ajax的一种便捷方式是jQuery Ajax: http://api.jquery.com/jQuery.ajax [ ^ ]。



如果您需要学习jQuery(强烈推荐),请参阅:

http://en.wikipedia.org/wiki/JQuery [ ^ ],

http://jquery.com [ ^ ],

http://learn.jquery.com [ ^ ],

http://learn.jquery.com/using-jquery-core [ ^ ],

http://learn.jquery.com/about-jquery/how-jquery-works [ ^ ](从这里开始)。



-SA
Your request for "rows to be added dynamically without post back" is simply self-contradictory. What you do with Javascript (and which can be done in a most convenient way using jQuery) happens only on the client side. From the standpoint of the ASP.NET application, it's server side (code behind), you new rows simply do not exist. So, what would you expect?

Nothing happens on the server side before you send some HTTP request from the client side. One of the way to do it directly is using Ajax:
http://en.wikipedia.org/wiki/Ajax_%28programming%29[^],
http://www.xul.fr/en-xml-ajax.html[^].

And just one of the convenient ways of using Ajax is the jQuery Ajax: http://api.jquery.com/jQuery.ajax[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com[^],
http://learn.jquery.com[^],
http://learn.jquery.com/using-jquery-core[^],
http://learn.jquery.com/about-jquery/how-jquery-works[^] (start from here).

—SA