将gridview项目传递到Jquery UI内的文本框和下拉列表?

时间:2016-02-24 08:01:45

标签: jquery asp.net

有没有办法将gridview中选定行的值传递给jQueryUI对话框中的文本框和下拉列表?我能够传递标签中的值,但我希望它在文本框和下拉列表中。这是我将代码传递给标签的代码:

<div class="modultext"><span>Sample text</span></div>
var prm = Sys.WebForms.PageRequestManager.getInstance();
$(document).on("click", "[id*=LinkButton1]", function () {
    $("[id*=lblNameView]").html($(".name", $(this).closest("tr")).html());
    $("[id*=lblLocationView]").html($(".Locationd", $(this).closest("tr")).html());
    var dlg = jQuery("#dialogViewing").dialog({
        modal: true,
        title: "View Audit Findings",
        resizable: true,
        width: 480,
        height: 290,
        show: {
            effect: "blind",
            duration: 200
        },
        hide: {
            effect: "blind",
            duration: 200
        },
    });
    return false;
   dlg.parent().appendTo(jQuery("form:first"));
});

更新

<Columns>
    <asp:BoundField DataField="name" ItemStyle-CssClass="name" HeaderText="Tenant Name" SortExpression="TenantCode" />
    <asp:BoundField DataField="Locationd" ItemStyle-CssClass="Locationd" HeaderText="Location" SortExpression="Locationd" />
    <asp:TemplateField>
        <ItemTemplate>
            <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
        </ItemTemplate>
    </asp:TemplateField>
</Columns>

1 个答案:

答案 0 :(得分:1)

你可以这样做:

dlg.find("input[id*=lblName]").val($(".name", $(this).closest("tr")).html())
dlg.find("select[id*=ddlLocation]").val($(".Locationd", $(this).closest("tr")).html())