enable checkbox inside gridview javascript
-
i do have 2 gridviews in my page, both of which contains check boxes. i need to uncheck and enable second gridview when any of the checkbox from first gridview is selected and vice versa.
-
i do have 2 gridviews in my page, both of which contains check boxes. i need to uncheck and enable second gridview when any of the checkbox from first gridview is selected and vice versa.
Here is a demo example, i m takin two grids and than disabling and enabling the second one through checkbox click in first one through javascript. .aspx code
Javascript:-
function SelectAll(id) { //get reference of GridView control if(document.getElementById(id).checked) { var grid = document.getElementById("<%= GridView2.ClientID %>") grid.style.visibility = "visible"; } else { var grid = document.getElementById("<%= GridView2.ClientID %>") grid.style.visibility = "hidden"; } }
modified on Friday, May 7, 2010 4:00 AM
-
i do have 2 gridviews in my page, both of which contains check boxes. i need to uncheck and enable second gridview when any of the checkbox from first gridview is selected and vice versa.
1. You need to put a javascript function in each checkbox in row in first gridview. in that checkbox you call the javascript function as follows
;
2. Following would be your javascript function defination
function EnableBelowGrid()
{
var chkBoxID = arguments[0];
if(document.getElementByID(chkBoxID).checked)
{
document.getElementById('<%=BelowGridID.ClientID%>').disabled = true
}
return false;
}Assumed that "BelowGridID" is the ID of your below grid as you have refered.
Thanks, Arindam D Tewary
-
Here is a demo example, i m takin two grids and than disabling and enabling the second one through checkbox click in first one through javascript. .aspx code
Javascript:-
function SelectAll(id) { //get reference of GridView control if(document.getElementById(id).checked) { var grid = document.getElementById("<%= GridView2.ClientID %>") grid.style.visibility = "visible"; } else { var grid = document.getElementById("<%= GridView2.ClientID %>") grid.style.visibility = "hidden"; } }
modified on Friday, May 7, 2010 4:00 AM