Question

I have a gridview which has some templatefield. At cell5 i have a label which is the input for database. but not all the labels in all the rows contains the value. its based on the click event of an editTemplateField. I have vb.net code for accessing that label inside the gridview. but i want to get it by javascript. following is the sample vb.net code and javascript that i have tried so far.

For Each i as gridViewRow in gridview.Rows
    Dim lnk as linkbutton = CType(i.FindControl("del"),LinkButton)
    If lnk.ForeColor = Drawing.Color.Red
        pid = CType(gridview.Rows(i).FindControl("lblposid"), Label).Text 
    End If
Next

javascript:

for (var i = 0; i < grid.rows.length-1; i++) {
 if(grid.rows[i].cells[1].style.color == "red")
 pid = grid.rows[i].cells[5].innerHTML;
}

vb.net works . but javascript is not working. i dont know how to make it in javascript.Thanks in advance]

Note: The template field's visible is "False" also.

Was it helpful?

Solution

I found my own solution now.

for (var i = 1; i < grid.rows.length; i++) 
{
 var links = grid.rows[i].getElementsByTagName("a");
 if(links[1].style.color=="red")
 {
 var spanlist = grid.rows[i].getElementsByTagName("span");
 pid=spanlist[1].innerHTML;
 links[1].style.color="blue";
 }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top