如何访问使用JavaScript GridView的单元格的值 [英] How to access gridview cell value with javascript

查看:182
本文介绍了如何访问使用JavaScript GridView的单元格的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我试图验证一个GridView的输入JavaScript函数。我的问题是我不能让单元格的值。以下是我有:

I have a javascript function that I am trying to validate the inputs of a gridview. My problem is that I cannot get the value of the cell. Here is what I have:

    function fcnCheck() {
        var grid = document.getElementById("<%= GridViewProducts.ClientID %>");
        var cellPivot;

        if (grid.rows.length > 0) {
            for (i = 1; i < grid.rows.length-1; i++) {
                cellPivot = grid.rows[i].cells[0];
                cellStatus = grid.rows[i].cells[1];
                if (cellPivot == "Yes" and cellStatus == "") {
                    alert("You must select an answer for all columns if Pivot is yes")
                    return false;
                }
            }
        }
    }

这行不起作用:cellPivot = grid.rows [I] .cells [0];

This line does not work: cellPivot = grid.rows[i].cells[0];

推荐答案

最有可能你想(编辑)

var theDropdown = grid.rows[i].cells[0].elements[0];    
var selIndex = theDropdown.selectedIndex;
cellPivot = theDropdown.options[selIndex].value;

另一个可能更容易或更可靠的方式来做到这将是标签细胞控制你想以某种方式,直接选择它们?

Another possibly easier or more reliable way to do this would be to tag the cells controls you want in some way and select them directly?

这篇关于如何访问使用JavaScript GridView的单元格的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆