Click here to Skip to main content
16,004,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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???
Posted

U can bind its disabled property with your database column. In this way u can enable and disable with that value
 
Share this answer
 
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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900