在gridview中为按钮单击添加事件处理程序 [英] add an event handler for button click in a gridview

查看:87
本文介绍了在gridview中为按钮单击添加事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要以这样一种方式将按钮添加到我的网格中,即当一个人单击该按钮时,该按钮应被禁用,而另一个按钮应在同一网格中被启用..
详细说明...网格中的每一行都需要有两个按钮,并且在单击第一个按钮时应该启用第二个按钮,并且应该禁用第一个按钮...

ne的想法?

谢谢,


i need to add buttons to my grid in such a way that when a person clicks on the button,that button should get disabled and another button should get enabled in the same grid..
to elaborate...each row in my grid needs to have two buttons and the second button should be enabled when the first button is clicked and the first button should be disabled...

ne ideas??

Thanks,

推荐答案

我有很多想法,但是解决方案取决于您是否要对此进行回发.如果您不想执行回发,则可以使用jQuery在click事件处理程序中进行管理.有很多示例显示了如何执行此操作,但是这里是您要查看的语法类型的示例:
I have many ideas, but the solution depends on whether or not you want to do a postback with this. If you don''t want to do a postback, I''d use jQuery to manage this in the click event handler. There are many examples showing how to do this, but here''s a sample of the type of syntax you''d be looking at:


(' #myId').click(function(){
('#myId').click(function() {


(' #myOtherButton').attr(' 已禁用'' 已启用' ); });
('#myOtherButton').attr('disabled','enabled'); });


OP希望获得更多信息.如果您不知道,jquery是一个JavaScript框架,可让开发客户端功能变得轻而易举.您需要从 JQuery [ ^ ],并将其作为包含项添加到您的网页中.然后,您将连接到上面显示的javascript,将#myId和#myOtherButton替换为脚本的内部页面中加载时触发的脚本中的相关ID.然后将click事件连接到按钮.


The OP wanted further information. In case you don''t know, jquery is a javascript framework that makes developing client side functionality an absolute breeze. You need to download the jquery library from JQuery[^] and add it into your web page as an include. Then, you''d hook up to the javascript I showed above, replacing #myId and #myOtherButton with the relevant ids inside a script that is fired when your page loads. The click event is then hooked up to the button.


这篇关于在gridview中为按钮单击添加事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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