js獲取GridView中行數(shù)據(jù)的兩種方法 分享
更新時(shí)間:2013年07月13日 13:45:00 作者:
這篇文章介紹了js獲取GridView中行數(shù)據(jù)的方法,有需要的朋友可以參考一下
第一種方法:
function submitData() {
var tb = document.getElementById(IDArray[0]); //獲取服務(wù)器控件GridView的ID
if (tb)
{
var rows = tb.rows;
for (var i = 1; i < rows.length; i++) {
var id = rows[i].cells[1].innerText;
var name = rows[i].cells[2].innerHTML;
var oDropDownList = rows[i].cells[3].childNodes[0];
var oText = oDropDownList.options[oDropDownList.selectedIndex].text; //獲取GridView中下拉列表中選中的文本
var oValue = oDropDownList.options[oDropDownList.selectedIndex].value;; //獲取GridView中下拉列表中選中的值
}
}
}
第二種方法:
function submitData() {
var tb = document.getElementById(IDArray[0]);
if (tb.hasChildNodes) {
if (tb.childNodes[0] != null) {
var rowCount = tb.childNodes[0].childNodes.length;
for (var i = 1; i < rowCount; i++) {
var child = tb.childNodes[0].childNodes[i];
var id = rowCount[i].cells[1].innerHTML;
var name = child.childNodes[1].innerHTML;
var oDropDownList = child.childNodes[2].childNodes[0];
var oText = oDropDownList.options[oDropDownList.selectedIndex].text;
var oValue = oDropDownList.options[oDropDownList.selectedIndex].value
}
}
}
復(fù)制代碼 代碼如下:
function submitData() {
var tb = document.getElementById(IDArray[0]); //獲取服務(wù)器控件GridView的ID
if (tb)
{
var rows = tb.rows;
for (var i = 1; i < rows.length; i++) {
var id = rows[i].cells[1].innerText;
var name = rows[i].cells[2].innerHTML;
var oDropDownList = rows[i].cells[3].childNodes[0];
var oText = oDropDownList.options[oDropDownList.selectedIndex].text; //獲取GridView中下拉列表中選中的文本
var oValue = oDropDownList.options[oDropDownList.selectedIndex].value;; //獲取GridView中下拉列表中選中的值
}
}
}
第二種方法:
復(fù)制代碼 代碼如下:
function submitData() {
var tb = document.getElementById(IDArray[0]);
if (tb.hasChildNodes) {
if (tb.childNodes[0] != null) {
var rowCount = tb.childNodes[0].childNodes.length;
for (var i = 1; i < rowCount; i++) {
var child = tb.childNodes[0].childNodes[i];
var id = rowCount[i].cells[1].innerHTML;
var name = child.childNodes[1].innerHTML;
var oDropDownList = child.childNodes[2].childNodes[0];
var oText = oDropDownList.options[oDropDownList.selectedIndex].text;
var oValue = oDropDownList.options[oDropDownList.selectedIndex].value
}
}
}
您可能感興趣的文章:
- ASP.NET GridView控件在列上格式化時(shí)間及DataFormatString使用
- asp.net DataFormatString格式化GridView
- ASP.NET數(shù)據(jù)綁定GridView控件使用技巧
- ASP.NET數(shù)據(jù)綁定之GridView控件
- 利用jQuery及AJAX技術(shù)定時(shí)更新GridView的某一列數(shù)據(jù)
- asp.net中GridView數(shù)據(jù)鼠標(biāo)移入顯示提示信息
- DevExpress實(shí)現(xiàn)GridView當(dāng)無數(shù)據(jù)行時(shí)提示消息
- asp.net讀取excel中的數(shù)據(jù)并綁定在gridview
- 使用ajax局部刷新gridview進(jìn)行數(shù)據(jù)綁定示例
- c#利用Excel直接讀取數(shù)據(jù)到DataGridView
- C#與SQL連接:GridView控件對(duì)數(shù)據(jù)庫的操作
- asp.net Gridview數(shù)據(jù)列中實(shí)現(xiàn)鼠標(biāo)懸浮變色
- Gridview利用DataFormatString屬性設(shè)置數(shù)據(jù)格式的方法
相關(guān)文章
工作中常用的js、jquery自定義擴(kuò)展函數(shù)代碼片段匯總
本文主要對(duì)工作中常用的js、jquery自定義擴(kuò)展函數(shù)代碼片段進(jìn)行了分享,具有很好的參考價(jià)值,需要的朋友一起來看下吧2016-12-12
詳解小程序中h5頁面onShow實(shí)現(xiàn)及跨頁面通信方案
這篇文章主要介紹了小程序中h5頁面onShow實(shí)現(xiàn)及跨頁面通信方案,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-05-05
微信小程序?qū)崿F(xiàn)的canvas合成圖片功能示例
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)的canvas合成圖片功能,結(jié)合實(shí)例形式分析了微信小程序canvas合成圖片相關(guān)組件使用、操作步驟與注意事項(xiàng),需要的朋友可以參考下2019-05-05
JavaScript實(shí)現(xiàn)班級(jí)抽簽小程序
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)班級(jí)抽簽小程序,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-05-05
javascript動(dòng)態(tài)創(chuàng)建表格及添加數(shù)據(jù)實(shí)例詳解
這篇文章主要介紹了javascript動(dòng)態(tài)創(chuàng)建表格及添加數(shù)據(jù),以實(shí)例形式分析了javascript動(dòng)態(tài)創(chuàng)建表格的常用方法,包括不兼容IE6與兼容IE6的實(shí)現(xiàn)方法,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-05-05
JS從數(shù)組中隨機(jī)取出幾個(gè)數(shù)組元素的方法
JS如何從一個(gè)數(shù)組中隨機(jī)取出一個(gè)元素或者幾個(gè)元素呢?其實(shí)方法很簡(jiǎn)單,下面小編給大家分享了JS隨機(jī)取出幾個(gè)數(shù)組元素的方法,非常不錯(cuò),需要的朋友參考下2016-08-08
JavaScript中async與await實(shí)現(xiàn)原理與細(xì)節(jié)
這篇文章主要介紹了JavaScript中async與await實(shí)現(xiàn)原理與細(xì)節(jié),文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09

