0

我的网格视图看起来像:

 <asp:GridView ID="gvFiles" runat="server" >
                                <Columns>
 <asp:TemplateField HeaderText="Notification Sent to">
                                        <ItemTemplate>
                                            <asp:Label ID="lblNotifSentTo" runat="server" CssClass="NotifSent"></asp:Label>
                                            <asp:HyperLink ID="hypNotifSentTo" runat="server"  CssClass="NotifSent2" NavigateUrl="#" 
                                                Text='<%# Eval("NotifSentToLabsStr") %>'></asp:HyperLink>
                                        </ItemTemplate>
                                    </asp:TemplateField>
  <asp:TemplateField>
                                        <ItemStyle Wrap="false" />
                                        <ItemTemplate>
                                            <div id="divIbtnEdit" runat="server" style="display: inline;">
                                                <asp:ImageButton ID="ibtnDelete" runat="server" ImageUrl="~/Images/Delete.gif"
                                                    ToolTip="Delete" />
                                                &nbsp;
                                            </div>
.......

当我单击删除按钮时,我需要在执行任何其他操作之前检查“发送到的通知”超链接的值,但我似乎无法获取该值

这就是我现在所拥有的:

 $("input[id*='_ibtnDelete_']").live("click", function ($e) {

            var id = $(this).next('NotifSent2').val();
            var nm = $(this).find('input[id$=NotifSent2]').val();

            var nm = $(this).parent.find('input[id$=NotifSent2]').val();
            var x = $(this).find('[id$="NotifSent2"]').val();
            return confirm(x);



            if ($(this).attr('src') == "Images/Delete_gray.gif") {
                alert("This request cannot be deleted, because it is currently linked to other files. ");
                return false;
            }

            else {
                return confirm('Are you sure you want to delete this file?');
            }
        });

我不断得到“未定义”

我究竟做错了什么?请帮忙。

这是生成的html:

<table cellspacing="0" cellpadding="8" id="ContentPlaceHolder1_gvFiles" style="background-color:White;border-color:#CCCCCC;border-width:1px;border-style:Solid;width:100%;border-collapse:collapse;">
                    <tr align="left" style="color:White;background-color:#ABAAC1;font-weight:bold;">
                        <th scope="col">&nbsp;</th><th scope="col">&nbsp;</th><th scope="col">&nbsp;</th><th scope="col">Type of Request</th><th scope="col">Status</th><th scope="col">Sender</th><th scope="col">Upload Date (EST)</th><th scope="col">Notification Sent to</th><th scope="col">&nbsp;</th><th scope="col">&nbsp;</th>
                    </tr><tr class="gvRowReqIncomplete">
                        <td>
                                            <td>HQ</td><td>10/23/2012 12:41:19 PM</td><td>
                                            <span id="ContentPlaceHolder1_gvFiles_lblNotifSentTo_0" class="uglyRed" style="display:inline;">No Recipient Selected!</span>
                                            <a id="ContentPlaceHolder1_gvFiles_hypNotifSentTo_0" class="NotifSent2" href="#" style="display:none;"></a>
                                        </td><td>

                                            <a id="ContentPlaceHolder1_gvFiles_hypResend_0" style="font-weight:bold;cursor:pointer;">Send Reminder</a>
                                        </td><td style="white-space:nowrap;">
                                            <div id="ContentPlaceHolder1_gvFiles_divIbtnEdit_0" style="display: inline;">
                                                <input type="image" name="ctl00$ContentPlaceHolder1$gvFiles$ctl02$ibtnEdit" id="ContentPlaceHolder1_gvFiles_ibtnEdit_0" title="Edit" src="Images/Edit.gif" />
                                                &nbsp;
                                            </div>
                                            <div id="ContentPlaceHolder1_gvFiles_divIbtnDelete_0" style="display: inline;">
                                                <input type="image" name="ctl00$ContentPlaceHolder1$gvFiles$ctl02$ibtnDelete" id="ContentPlaceHolder1_gvFiles_ibtnDelete_0" title="Delete" src="Images/Delete.gif" />
                                                &nbsp;
                                            </div>
                                            <div id="ContentPlaceHolder1_gvFiles_divIbtnUpdate_0" style="display: none;">
                                                <input type="image" name="ctl00$ContentPlaceHolder1$gvFiles$ctl02$ibtnUpdate" id="ContentPlaceHolder1_gvFiles_ibtnUpdate_0" title="Update" src="Images/Update.gif" />
                                                &nbsp;
                                            </div>
                                            <div id="ContentPlaceHolder1_gvFiles_divIbtnCancel_0" style="display: none;">
                                                <input type="image" name="ctl00$ContentPlaceHolder1$gvFiles$ctl02$ibtnCancel" id="ContentPlaceHolder1_gvFiles_ibtnCancel_0" title="Cancel" src="Images/Cancel.gif" />
                                            </div>
                                        </td>
                    </tr>
                </table>
4

3 回答 3

1

NotifSent2 是一个你必须使用的类。带类选择器

改变

 var id = $(this).next('NotifSent2').val();

    var id = $(this).next('.NotifSent2').val();
于 2012-10-23T16:32:26.983 回答
1

试试这个:

var id = $(".NotifSent2", $(this).closest("tr")).html();
于 2012-10-23T16:44:30.217 回答
0

试试这个

$('table[id$=gvFiles] tr input[id$=ibtnDelete]').click(function(){
    var val=$(this).closest('tr').find('a[id$=hypNotifSentTo]').html();
    alert(val);
    });
于 2012-10-23T18:10:44.130 回答