Click here to Skip to main content
16,019,263 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Scenario:

In my gridview header there are checkbox and textbox.

If i check gridview header checkbox and provide approve /reject status in textbox.

Every rows of gridview checkbox and textbox will be disabled and updated with status of gridview header textbox.

for example-
in header textbox if i write approve in textbox each rows will be updated with approve and will be updated in database.


secondly if i check gridview rows checkbox and textbox will be enable and alternatly relevant field will be updated..

help would be appreciable...
Posted
Comments
LLLLGGGG 10-Jun-14 14:23pm    
Just a little piece of code would be appreciated in order to understand the problem... just the code you used. If you used winform, maybe, even the designer.cs file.
Peter Leow 10-Jun-14 14:50pm    
You have an "enable/disable all" kind of textbox in the header, why textbox? It offers no control to what a user can enter, including typo. Why not a dropdownlist with approve and reject items for selection.
Your checkbox idea may confuse the users, you may want to re-think and re-work.

1 solution

This could be achieved by using javascript.

Javascript for select/unselect checkbox:
JavaScript
function selectAllCheckBox(event, containerId, boolChecked) {
    var collection = document.getElementById(containerId).getElementsByTagName('INPUT');
    for (var x = 0; x < collection.length; x++) {
        if (collection[x].type.toUpperCase() == 'CHECKBOX')
            collection[x].checked = boolChecked;
    }
    event.preventDefault();
    return false;
}

Javascript for updating all textbox:
JavaScript
function changeReadOnly(event,containerId,isReadOnly) {
	var collection = document.getElementById(containerId).getElementsByTagName('INPUT');
    for (var x = 0; x < collection.length; x++) {
        if (collection[x].type.toUpperCase() == 'TEXT')
            collection[x].readOnly = isReadOnly;
    }
    event.preventDefault();
    return false;
}


Sample HTML:

HTML
<input type="submit" value="select all" onclick="return selectAllCheckBox(event,'divGrid', true);">
<input type="submit" value="select none" onclick="return selectAllCheckBox(event,'divGrid', false);">
<input type="submit" value="Read Only = true" onclick="return changeReadOnly(event,'divGrid',true);">
<input type="submit" value="Read Only = false" onclick="return changeReadOnly(event,'divGrid',false);">



<div id="divGrid">

<!--GridView goes here-->

</div>
 
Share this answer
 
v3

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