【问题标题】:Get value of hidden field in Grid using JQuery使用 JQuery 获取 Grid 中隐藏字段的值
【发布时间】:2013-01-14 15:05:12
【问题描述】:

我有一个 RadGrid,它生成以下 html(每行隐藏 ID 更改):

<input id="hiddenID" type="hidden" value="c6be9aaf-fc2b-441b-886e-120cfd6a73ee5" name="gvClaimDtSentDate$ctl00$ctl18$Detail50$ctl04$hiddenID">
<a id="c6be9aaf-fc2b-441b-886e-120cfd6a73ee" class="viewBtn" href="#">View</a>
<a class="orderBtn" id="lnkOrder" href="#">My Order</a>

我想在点击 lnkOrder 时获取原始的隐藏 ID。所以我在下面做了,但它不起作用,因为它给了我每行的静态/相同的 id:

$('.orderBtn').click(function() {

            var tr = $("#<%=gvDtSentDate.ClientID%> tr");
            var id = tr.find("input[name$=hiddenID]").val();

有人可以帮忙吗。

【问题讨论】:

    标签: jquery asp.net radgrid hidden-field


    【解决方案1】:

    试试这个:

    $('.orderBtn').click(function() {
        var $tr = $(this).closest('tr'); // gets closest parent tr element to the a
        var id = $tr.find("input[name$=hiddenID]").val();
        // if hidden input is the only one in the row you could simplify this to:
        // var id = $tr.find("input").val();
    });
    

    【讨论】:

      猜你喜欢
      • 2011-03-12
      • 2011-03-06
      • 1970-01-01
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 2013-12-30
      • 1970-01-01
      • 2013-09-12
      相关资源
      最近更新 更多