如何获取java-script或jquery中的网格视图标签值?

时间:2015-10-05 14:41:31

标签: javascript jquery

<asp:GridView ID="GVPurchaseRequest">

  <asp:TemplateField HeaderStyle-HorizontalAlign="Center"  HeaderText="Select">
    <ItemTemplate>
      <asp:Label ID="lblCheckStatus" runat="server" Text='<%# Eval("CheckStatus")%>' style="display:none"></asp:Label>
      <asp:Label ID="lblLevelAdded" runat="server" Text='<%# Eval("LevelAdded")%>' style="display:none"></asp:Label>
      <asp:Label ID="lblAdded_UserID" runat="server" Text='<%# Eval("Added_UserID")%>' style="display:none"></asp:Label>
      <asp:Label ID="lblEjectLevel" runat="server" Text='<%# Eval("LevelEjected")%>' style="display:none"></asp:Label>
      <asp:Label ID="lblCheckReturnStatus" runat="server" Text='<%# Eval("CheckReturnStatus")%>' style="display:none"></asp:Label>
      <asp:Label ID="lbl_status" runat="server" Text='<%# Eval("status")%>'></asp:Label> 
      <asp:CheckBox ID="chkPRID" runat="server" Checked="true" OnClientclick="javascript: return test();"  />      
      <asp:Label ID="lblConPo" runat="server" Text='<%# Eval("Con_To_PO")%>' style="display:none"></asp:Label>                                                                     
      <asp:Label ID="lblConPoF" runat="server" Text="0" style="display:none"></asp:Label>
      <asp:Label ID="lblPR_ID" runat="server" Text='<%# Eval("PR_ID")%>' style="display:none"></asp:Label>
      <asp:Label ID="lblrowIDnd" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID") %>' Style="display:none"></asp:Label>
      <asp:Label ID="lblPR_IDF" runat="server" Text="0" style="display:none"></asp:Label>                                                                                                                                                         <asp:ImageButton ID="btnDelGV" runat="server" CommandArgument='<%#Bind("ID") %>' ToolTip="Delete" AlternateText="Delete" CommandName="Delete" ImageUrl="~/Images/Delete_24x24.png" OnClientClick="javascript:return deletePartNo();"></asp:ImageButton>                                                                        </ItemTemplate>
    </asp:DataGrid>

问题

如何在 jquery JavaScript 中获取lbl_status标签值?...

1 个答案:

答案 0 :(得分:0)

您可以添加一个按钮来获取值吗?

我没有测试过,但你可以试一试。

//LinkButton
<asp:LinkButton ID="lnk" Text="Click Here" runat="server" OnClientClick="getLabelValue(this);" />

 //function
<script type="text/javascript">
    function getLabelValue(element)
    {
        var label = $(element).closest('label').find('label[id*="lbl_status"]').text();
        console.log(label);
    }
</script>

或者您可以尝试这样做:

var label = $("#GVPurchaseRequest").closest('label').find('label[id*="lbl_status"]').text();
        console.log(label);