在JavaScript中获取asp:listview模板项客户端ID [英] get asp:listview template items client id in javascript

查看:84
本文介绍了在JavaScript中获取asp:listview模板项客户端ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,

我在更新面板中有一个asp:listview。在列表视图中有一个gridview作为模板。

I have an asp:listview inside update panel. inside list view there is a gridview as template.

我们如何在Javascript中获取Gridview的客户端ID并循环遍历gridview项目。

how can we get client id of the Gridview in Javascript and loop through the gridview items.

非常感谢帮助。

问候,

海军

海军

推荐答案

尝试使用:



try with:

window.onload = function () {
    var table, tbody, i, rowLen, row, j, colLen, cell;

    table = document.getElementById("GridView1");
    tbody = table.tBodies[0];

    for (i = 0, rowLen = tbody.rows.length; i < rowLen; i++) {
        row = tbody.rows[i];
        for (j = 0, colLen = row.cells.length; j < colLen; j++) {
            cell = row.cells[j];
            if (j == 1) {
                // Gender
                console.log("--Found gender: " + cell.innerHTML);
            } else if (j == 2) {
                // Age
                console.log("--Found age: " + cell.innerHTML);
            }
        }
    }
};


请在此处阅读:  使用javascript循环浏览asp:GridView数据

Read here: Looping through asp:GridView data using javascript


这篇关于在JavaScript中获取asp:listview模板项客户端ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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