how can i access the controls in a gridview cells in which i use for inline edit? In the gridview, there would be two controls in a cell, which is a label and a textbox. When user navigate around the gridview, next cell would turns textbox become visible and label become invisible. How can i enhance the code below. I'm not familiar with javascript, hope u guys can help.....
function NavigateCell() {
if (event.keyCode == 37) { //to the left
if (currentCellReference.previousSibling.cellIndex != 0) {
currentCellReference.style.borderWidth = 1;
currentCellReference.previousSibling.style.borderWidth = 3;
currentCellReference = currentCellReference.previousSibling;
grid.focus();
}
}
else if (event.keyCode == 38) { //up
if (currentCellReference.parentElement.previousSibling.rowIndex != 0) {
currentCellReference.style.borderWidth = 1;
currentCellReference.parentElement.previousSibling.children[currentCellReference.cellIndex].style.borderWidth = 3;
currentCellReference = currentCellReference.parentElement.previousSibling.children[currentCellReference.cellIndex];
grid.focus();
}
}
else if (event.keyCode == 39 || event.keyCode == 9) { //to the right
if (currentCellReference.nextSibling != null) {
currentCellReference.style.borderWidth = 1;
currentCellReference.nextSibling.style.borderWidth = 3;
currentCellReference = currentCellReference.nextSibling;
grid.focus();
}
}
else if (event.keyCode == 40 || event.keyCode == 13) { //down
if (currentCellReference.parentElement.nextSibling != null) {
currentCellReference.style.borderWidth = 1;
currentCellReference.parentElement.nextSibling.children[currentCellReference.cellIndex].style.borderWidth = 3;
currentCellReference = currentCellReference.parentElement.nextSibling.children[currentCellReference.cellIndex];
grid.focus();
}
}
else {
if (currentCellReference != null)
currentCellReference.children[0].focus();
}
}