按钮禁用 [英] Button Disable

查看:94
本文介绍了按钮禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带复选框的datagrid.该复选框根据每行的列中的值启用或禁用.页面中还有一个按钮.如果要禁用所有复选框,我想禁用该按钮.任何人都可以帮助我吗?

Hi,
I have a datagrid with checkbox. The checkbox is enabled or disables according to the value in a colum of each row. There is also a button in the page. I want to disable the button if all the checkboxes are disabled.CAn anyone help me???

推荐答案

U可以将其Disabled属性与您的数据库列绑定.这样,您可以使用该值启用和禁用
U can bind its disabled property with your database column. In this way u can enable and disable with that value


在您的数据网格的ItemDataBound(或RowDataBound)中:
1.您知道此处要显示的记录数(数据集行数)-X
2.根据决定复选框值的字段设置计数器(Y)并跟踪禁用的行数
3.在循环结束时,绑定数据后,检查设置的计数器是否等于总行数(X == Y?).如果是这样,请禁用服务器端的按钮.否则,保持原样.

P.S .:将跟踪禁用的行数的计数器应该是全局变量,而不是局部变量.
In your datagrid''s ItemDataBound(or RowDataBound):
1. You know the number of records to be displayed here (Dataset row count) - X
2. Setup a counter (Y) and track number of rows disabled based on the field that is deciding the checkbox value
3. At the end of the loop, when the data is binded, check if the counter you set is equal to total row count (X==Y?). If so, disable the button on server side. Or else, leave it as it is.

P.S.: The counter that will track number of rows disabled should be global variable and not local.


hello,

我已经在网格"视图中完成了.
如果选中了任何复选框,则Gridview外部的按钮处于启用状态,如果未选中,则该按钮是可透析的.

您可以对其进行修改并可以使用.

< script type ="text/javascript">
功能检查(chkB){
//var IsChecked = alert(document.getElementById(chkB));
如果(chkB.checked){
document.getElementById("ctl00_ContentPlaceHolder1_btnRemove").disabled = false;
}
其他{
document.getElementById("ctl00_ContentPlaceHolder1_btnRemove").disabled = true;
}

}
</script>


并在复选框上:

onClick ="check(this)"

这会起作用.


javascript中的此ID是自动创建的按钮运行时ID
"ctl00_ContentPlaceHolder1_btn删除"

我的按钮ID是btnRemove,但是在运行时已创建.
hello,

I have done in the Grid view.
If any check box is checked then the button outside gridview is Enabled and if not checked then the button is diasabled.

You can modify it and can use.

<script type="text/javascript">
function check(chkB) {
//var IsChecked = alert(document.getElementById(chkB));
if (chkB.checked) {
document.getElementById("ctl00_ContentPlaceHolder1_btnRemove").disabled = false;
}
else {
document.getElementById("ctl00_ContentPlaceHolder1_btnRemove").disabled = true;
}

}
</script>


and on checkbox:

onClick="check(this)"

this will work.


this id in the javascript is buttons runtime id that is created automatically
"ctl00_ContentPlaceHolder1_btnRemove"

my button id is btnRemove,but at runtime thats created.


这篇关于按钮禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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