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控件對數(shù)據(jù)庫的操作
- asp.net Gridview數(shù)據(jù)列中實(shí)現(xiàn)鼠標(biāo)懸浮變色
- Gridview利用DataFormatString屬性設(shè)置數(shù)據(jù)格式的方法
相關(guān)文章
使用auto.js實(shí)現(xiàn)自動(dòng)化每日打卡功能
這篇文章主要介紹了使用auto.js實(shí)現(xiàn)自動(dòng)化每日打卡,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08js實(shí)現(xiàn)精確到秒的倒計(jì)時(shí)效果
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)精確到秒的倒計(jì)時(shí)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05JS中比Switch...Case更優(yōu)雅的多條件判斷寫法
這篇文章主要給大家介紹了關(guān)于JS中比Switch...Case更優(yōu)雅的多條件判斷寫法,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用JS具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09JavaScript設(shè)計(jì)模式之建造者模式介紹
這篇文章主要介紹了JavaScript設(shè)計(jì)模式之建造者模式介紹,將一個(gè)復(fù)雜對象的構(gòu)造與它的表示相分離,使同樣的創(chuàng)建過程可有不同的表示,這就叫做建造者模式,需要的朋友可以參考下2014-12-12JavaScript返回0-1之間隨機(jī)數(shù)的方法
這篇文章主要介紹了JavaScript返回0-1之間隨機(jī)數(shù)的方法,涉及javascript中Math對象random方法的使用技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04