jeudi 22 janvier 2015

Checkbox check higlight gridview not working

I want a functionality where I want where, If I select one row, that particular row should get highlighted. I have written the javascript code, but it is not working properly



function Check_Click(objRef) {
var row = objRef.parentNode.parentNode;
if (objRef.checked) {
row.style.backgroundColor = "#FFF6BD";
}
else {
if (row.rowIndex % 2 == 0) {
row.style.backgroundColor = "#FFF6BD";
}
else {
row.style.backgroundColor = "white";
}
}
var GridView = row.parentNode;
var inputList = GridView.getElementsByTagName("input");
for (var i = 0; i < inputList.length; i++) {
var headerCheckBox = inputList[0];
var checked = true;
if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) {
if (!inputList[i].checked) {
checked = false;
break;
}
}
}
headerCheckBox.checked = checked;
}


Also see the gridview code for ref:-



<asp:TemplateField HeaderText="Select" ItemStyle-Width="30">
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" onClick="Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>




Aucun commentaire:

Enregistrer un commentaire