0
 <asp:DataGrid ID="datagrid1" runat="server" AutoGenerateColumns="False" Width="100%"
                    DataKeyField="Expr1" OnItemCommand="datagrid1_ItemCommand" EmptyDataText="No Records Found" 
                    >
                    <HeaderStyle BackColor="#2E882E" Font-Bold="True" ForeColor="#FFFFCC" HorizontalAlign="Left" />
                    <Columns>
                        <asp:TemplateColumn HeaderText="">
                            <ItemTemplate>
                                <table>
                                    <tr>
                                         <td class="style1">
<asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status") %>'></asp:Label>
                                        </td>
  </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                    </Columns>
                </asp:DataGrid>

jqueryPlease helpを使用してこのステータスラベル値にアクセスするにはどうすればよいですか

   var DataGrid1 = $("<%=datagrid1.ClientID %>");
var status = $(DataGrid1).children("lblStatus").get(0).innerHTML;

上記のコードは機能しますか?

編集:提案されたようにこのコードを使用してみました

 $(document).ready(function () {
        $('.vini').click(function () {
            //var status = $("#<%=ddlstatus.ClientID%>").val();
            var DataGrid1 = $("#<%=datagrid1.ClientID %>");
              var status =$(DataGrid1).find("txtStatDesc").html();




            if (status == 'Sent') {
                var _Action = confirm('Do you really want to cancel this payment ? All pending money will be available in the retention account of the contractor ');
                if (_Action) {
                    $.blockUI({ css: {
                        border: 'none',
                        padding: '15px',
                        backgroundColor: '#000',
                        '-webkit-border-radius': '10px',
                        '-moz-border-radius': '10px',
                        opacity: .5,
                        color: '#fff'
                    }
                    });
                    return true;
                }
                else {
                    return false;
                }


            }

        });
    }); 

ステータスは取得できませんが、

ここに画像の説明を入力

4

1 に答える 1

0

効果がないでしょう。becozlabelは の直接の子ではありませんdatagrid1。あなたはこのように使うことができます

 var DataGrid1 = $("<%=datagrid1.ClientID %>");
 $("#"+DataGrid1).find("label").html();

jqueryの子APIについて参照してください:

http://api.jquery.com/children/

于 2012-10-17T16:58:03.230 に答える