简体   繁体   中英

How to pass the value of a textbox in a datagrid to javascript

我的数据网格中有一个文本框,其ID需要传递给javascript。我的数据网格的ID为Datagrid1,文本框的ID为txtItem。所有这些都在contentplaceholder内部。现在,我将文本框的ID传递为ct100_ContentPlaceholder1_Datagrid1_txtItem。我的JavaScript中出现错误“对象引用未设置为对象实例”。如何将datagrid中此文本框的ID传递给javascript。

If you have a textbox inside your grid probably you have multiple instances of it, with JQuery you can access all textboxes inside your grid like that :

function getTextBoxesInsideGrid()
{
    var gridClientID = '<%= grid.ClientID %>';
    jQuery.each($("#" + gridClientID + " input[type='text']"), function ()
    {
      var textValue = this.val();
      // do something
    });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM