0

jqueryの専門家にとっては非常に簡単な小さな質問があります。http://aspdotnetcodebook.blogspot.com/2010/01/page-languagec-autoeventwireuptrue.htmlに従って、グリッドビューの行のダブルクリックでアクションを実行できるようにしています。(例に示すように)別のページにうまくリダイレ​​クトできますが、 $(this).find("a").click(); を引き起こすことはできません。発砲する。以下は私の GridView マークアップです。

<asp:GridView ID="gvCustomers" runat="server" DataSourceID="odsCustomers" CssClass="datagrid"
        GridLines="None" AutoGenerateColumns="False" DataKeyNames="Customer_ID" PageSize="3"
        AllowPaging="True" AllowSorting="True" OnRowCommand="gvCustomers_RowCommand"
        OnRowDataBound="gvCustomers_RowDataBound">
        <Columns>
            <asp:BoundField DataField="Customer_ID" HeaderText="ID" ReadOnly="true" Visible="false" />
            <asp:BoundField DataField="Customer_FirstName" HeaderText="First Name" ReadOnly="true" />
            <asp:BoundField DataField="Customer_LastName" HeaderText="Last Name" ReadOnly="true" />
            <asp:BoundField DataField="Customer_Email" HeaderText="Email" ReadOnly="true" />
            <asp:BoundField DataField="Customer_Mobile" HeaderText="Mobile" ReadOnly="true" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="lnkButton" runat="server" CommandName="showVehicles" CommandArgument='<%# Eval("Customer_ID") %>'
                        ></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            Sorry No Record Found.
        </EmptyDataTemplate>
    </asp:GridView>

著者が提案したように機能させることはできません: /* または、トリガーできる行 (Text="" または設定されていない) に非表示の LinkBut​​ton を含めることができます。CommandName="Something" と CommandArgument="RecordId" を必ず設定してください */

linkBut​​ton の OnCommand には、起動したいサーバー側のメソッドがあります。どんなアイデアでも大歓迎です。

ありがとう、アリ

4

1 に答える 1

0

以下のスクリプトを見ると、window.locationが設定されているため、リンクはクリックされません。ブログ投稿の内容を読むと、設定するwindow.locationか使用するかのいずれかで$(this).find("a").click();あり、両方を使用することはできません。

<script type="text/javascript">
    var selected = null;
    $(document).ready(function(){
        $("#gvCustomers").find("tr").click(function(){
            $(selected).removeClass("selected"); $(this).addClass("selected"); selected = this;
        });
        $("#gvCustomers").find("tr").dblclick(function(){
            var Id = $(this).find("td:nth-child(1)").text();
            //window.location = "/CustomersVehiclesWebSite/Default2.aspx?record=" + $(this).find("td:nth-child(1)").text();
            $(this).find("a").click();
        });
     });
     function doPostBack(element) {
     tb_remove();
     setTimeout('__doPostBack(\'' + element.name + '\',\'\')', 500);// 500ms given to thickBox to remove itself
     }
</script>
于 2010-06-03T12:25:23.083 に答える