Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JQuery模式窗口检索GridView中同一行上的TR数据_Jquery_Asp.net_Sharepoint_Gridview - Fatal编程技术网

如何使用JQuery模式窗口检索GridView中同一行上的TR数据

如何使用JQuery模式窗口检索GridView中同一行上的TR数据,jquery,asp.net,sharepoint,gridview,Jquery,Asp.net,Sharepoint,Gridview,我正在尝试跟踪此链接: 我在SP Visual Web部件中有以下GridView: <asp:GridView ID="BookingResults" runat="server" EnableModelValidation="True" AutoGenerateColumns="False" AllowSorting="true" ForeColor="Black"> <Columns> <asp:TemplateField>

我正在尝试跟踪此链接:

我在SP Visual Web部件中有以下GridView:

<asp:GridView ID="BookingResults" runat="server" EnableModelValidation="True" AutoGenerateColumns="False" AllowSorting="true" ForeColor="Black">
    <Columns>
        <asp:TemplateField>
            <HeaderTemplate>
                <asp:Label runat="server" ID="commHdr" Text="Show Guideline" />
            </HeaderTemplate>
            <ItemTemplate>
                <asp:LinkButton runat="server" ID="btnShow3" CssClass="btnSearch3" Text="VIEW" PostBackUrl="javascript:void(0);" OnClientClick="javascript:test();return false;"></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="ID" HeaderText="ID" ItemStyle-VerticalAlign="Top" />
        <asp:BoundField DataField="Topic" HeaderText="Topic" ItemStyle-VerticalAlign="Top"  />
        <asp:BoundField DataField="Location" HeaderText="Location" ItemStyle-VerticalAlign="Top" />
        <asp:BoundField DataField="Specialty" HeaderText="Specialty" ItemStyle-VerticalAlign="Top" />
        <asp:TemplateField HeaderText="Provider Name">
             <ItemTemplate>
                  <div style="width: 155px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                       <asp:Label ID="lblEllipsis" runat="server" Text='<%#Eval("Provider") %>' ToolTip='<%#Eval("Provider") %>'></asp:Label>
                  </div>
              </ItemTemplate>
         </asp:TemplateField>
        <asp:TemplateField HeaderText="Summary" ItemStyle-VerticalAlign="Top">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Summary") %>' CssClass="sumM"></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Summary") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Guideline" HeaderText="Guideline" ItemStyle-CssClass="gLine" HeaderStyle-CssClass="gLine" />
    </Columns>
</asp:GridView>
使用以下命令显示模式窗口:

<div id="dialog" style="display: none">
    <b>Id:</b> <span id="infoShow"></span>
</div>
在上面的示例中,单击“查看链接”时,模式窗口应显示:

<HTML>
     <p>
     THIS IS A TEST GUIDELINE BUT NOT SHOWN TO THE USER BUT WILL BE SHOWN IN THE MODEL WINDOW.
     </p>
</HTML>

以下是如何使演示正常工作:

首先,从标记中删除
标记

其次,从链接中删除
onclick=“javascript:test();return false;”

最后,将代码更改为()

请注意,在使用jQuery UI时,请包括适当版本的jQuery


编辑:问题中的代码不起作用的原因是
onclick
正在调用
test()
,而没有对元素进行任何引用。如果是这样的话:

onclick="javascript:test(this);return false;"
然后,测试功能可以执行以下操作:

function test(element) {
    // ...
    $("#infoShow").html($(".gLine", $(element).closest("tr")).html());
    // ...
}

您不应该在主
标记中的任何位置使用
标记来包装所有内容。它们都是与数据一起输入的,因此我将对其进行解码,然后显示在显示窗口中。它不是有效的HTML,浏览器和/或jQuery可能无法正确解释它。如果我希望按原样显示它,该怎么办?您可以将其放入iframe中,我想是吧,稍后jQuery?试试看它是否有效;它在那个演示中起作用。现在确定我做错了什么,但复制你起作用了。。。现在,如何在不显示HTML标记的情况下按原样显示HTML生成的文本?请尝试在另一个问题中提问,我不知道如何在其上使用asp.netAlready。我完全忘记投票了:)谢谢。我可以在10分钟内接受。。。到现在为止,一直都还不错!我在这里问:(如果你有兴趣看一看)
<HTML>
     <p>
     THIS IS A TEST GUIDELINE BUT NOT SHOWN TO THE USER BUT WILL BE SHOWN IN THE MODEL WINDOW.
     </p>
</HTML>
function test() {
    alert("test");
    $("#infoShow").html($(".gLine", $(this).closest("tr")).html());

    var tableData = $(this).children("td").map(function () {
        return $(this).text();
    }).get();
    alert(tableData[5]);
    $("#dialog").dialog({
        title: "View Guideline",
        buttons: {
            Ok: function () {
                $(this).dialog('close');
            }
        },
        modal: true
    });
}
$(function () {

    $('table a').click(function () {

        $("#infoShow").html($(".gLine", $(this).closest("tr")).html());
        $("#dialog").dialog({
            title: "View Guideline",
            buttons: {
                Ok: function () {
                    $(this).dialog('close');
                }
            },
            modal: true
        });
    });

});
onclick="javascript:test(this);return false;"
function test(element) {
    // ...
    $("#infoShow").html($(".gLine", $(element).closest("tr")).html());
    // ...
}