开发者

get value from a gridView from javascript

开发者 https://www.devze.com 2023-03-29 21:49 出处:网络
i have this code in ASP, I need to do the same, b开发者_开发问答ut from the client side. I´ve been searching but i couldn´t do the javascript work. I think this would be pretty simple.

i have this code in ASP, I need to do the same, b开发者_开发问答ut from the client side. I´ve been searching but i couldn´t do the javascript work. I think this would be pretty simple.

    protected void btnProbar_Click(object sender, EventArgs e)
    {
        bool flag = false;

        foreach(GridViewRow c in grdDatos.Rows)
        {
            if (c.Cells[0].Text == txtNroUnidad.Text)
            {
                flag = true;        
            }
        }
    }

If you could help me, I would apreciate that. Thanks you!


This is unchecked but it should be something like:

function ProBar
{
    // Declare the flag
    var flag = false;
    // Get the text we want to compare in the table
    var checkText = document.getElementById('txtNroUnidad').value;

    // Get the grid
    var grdDatos = document.getElementById('grdDatos');

    // Loop through each row
    // Starts at row 1 because I assume row 0 is a header row
    for (i=1;i<=grdDatos.rows.length;i++)
    {
        var currentRow = grdDatos.rows[i];

        if (currentRow.cells[0].value == checkText)
        {
            flag = true;
        }
    }

    return flag;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号