简体   繁体   English

按钮单击在updatepanel内的GridView内部不起作用

[英]Button click not working inside gridview inside updatepanel

I have a div that has a gridview inside an updatepanel, that I use bootbox.js to show modal. 我有一个在updatepanel内具有gridview的div,我使用bootbox.js来显示模式。 Inside the gridview is an itemtemplate with an asp.net button "Button1" which I need to click to edit the row after modalpopup but this doesnt fire Please what am I missing 在gridview内是一个带有asp.net按钮“ Button1”的itemtemplate,我需要单击它来编辑modalpopup之后的行,但这不会触发,请问我在想什么

<div id="userForm"  class="form-horizontal" style="display:none;width:100%;border:solid 0px;" >
        <input ID="btnshowRun" type="button" Value="Show Leave" class="btn btn-warning " style="float:lefts;" OnClick ="showhide();"/>

       <asp:UpdatePanel ID="UpdatePanel5" runat="server" style="display:none;">
            <ContentTemplate>
                <asp:GridView ID="GridView2" runat="server" AllowSorting="False" 
                    AutoGenerateColumns="False" DataKeyNames="EntryID"
                    EmptyDataText="There are no data records to display."
                    ShowFooter="False" HorizontalAlign="Center" OnRowCommand="gvl_RowCommand"
                    ShowHeaderWhenEmpty="True" CssClass="table table-striped table-bordered table-hover table-responsive table-condenseds " Width="100%" GridLines="None">
                    <Columns>
                        <asp:TemplateField HeaderText="Total" SortExpression="Total">
                            <EditItemTemplate>
                                <asp:TextBox ID="tot" runat="server" Text='<%# Bind("Total") %>' class="form-control"></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label4" runat="server" Text='<%# Bind("Total") %>'></asp:Label>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField ShowHeader="False">
                            <EditItemTemplate>
                                <asp:LinkButton ID="CommandButton" runat="server" CommandArgument='<%# Eval("EntryID") %>' UseSubmitBehaviour=true CausesValidation="False"
                                    CommandName="Update" OnCommand="Updates_Command" Text="Update" class="btn btn-primary btn-sm contrl" Style="margin-right: 10px;"
                                    />
                                &nbsp;<asp:LinkButton ID="Button2" runat="server" CausesValidation="False" CommandName="Cancel" class="btn btn-warning btn-sm contrl" Style="margin-right: 10px;"
                                    Text="Cancel" />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="Button1" runat="server" CommandArgument='<%# Eval("EntryID") %>' class="form-control btn btn-default btn-blocks contrl btn-sms"
                                    CommandName="Edit" OnCommand="Button1_Command" Text="Edit" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <HeaderStyle HorizontalAlign="Center" Font-Bold="True" ForeColor="Black"></HeaderStyle>
                </asp:GridView>
            </ContentTemplate>
           </asp:UpdatePanel>
    </div>

The problem with modals is that they usually place the contents outside of the <form> tag. 模态的问题在于它们通常将内容放置在<form>标记之外。 And then the Buttons do not work anymore. 然后按钮不再起作用。

Replace the Buttons with LinkButtons. 用LinkBut​​tons替换按钮。 They perform a PostBack with JavaScript and will work from a Modal. 他们使用JavaScript执行PostBack,并将在Modal中工作。

我没有处理rowediting事件,因此在firefox中检查开发人员视图时遇到错误。现在它可以触发我进行编辑,但是在第二次单击链接按钮后才启用编辑功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM