使用javascript从gridview中的下拉列表中获取所选项目 [英] get selected item from dropdownlist inside gridview using javascript

查看:70
本文介绍了使用javascript从gridview中的下拉列表中获取所选项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想从gridview中的dropdownlist中获取价值,我尝试通过gridview循环,但无法从dropdownlist获取值,我将代码放在下面..请帮助我谢谢...



代码:

 function checkUpdateOption(){

var gvET = document.getElementById( <%= GridView1.ClientID%> ;);
var rCount = gvET.rows.length;
alert(rCount);

for var rowIdx = 1 ; rowIdx< = rCount-1; rowIdx ++){


var cell = gvET.rows [ rowIdx] .cells [ 0 ]。getElementsByTagName( * )[ 0 ]。 value ;

alert(cell);


}
返回 false ;
}







在警告框中显示on值

解决方案

相反,我建议使用jQuery

将CssClass MyGridView附加到你的GridView和名为MyDropDown的类到DropDownList



然后,

 


' 。MyGridView')。find(' tr' ).each

function()
{
var CurrentDrownValue =


< blockquote>( this )。find(' 。MyDropDown' )。attr(' value');

}
);


Hi to all, I want to get value from dropdownlist inside gridview, i tried its loop through the gridview but not able to get the value from dropdownlist, i placed the code below.. please help me thanks ...

code:

function checkUpdateOption() {

            var gvET = document.getElementById("<%= GridView1.ClientID %>");
            var rCount = gvET.rows.length;
            alert(rCount);

            for (var rowIdx=1;rowIdx<=rCount-1;rowIdx++) {
            

 var cell = gvET.rows[rowIdx].cells[0].getElementsByTagName("*")[0].value;
               
 alert(cell);


            }
            return false;
        }




In Alert box it display "on" value

解决方案

Instead i suggest use jQuery
Attach CssClass MyGridView to your GridView and class called MyDropDown to DropDownList

then,


('.MyGridView').find('tr').each ( function() { var CurrentDrownValue=


(this).find('.MyDropDown').attr('value'); } );


这篇关于使用javascript从gridview中的下拉列表中获取所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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