【问题标题】:Button click not working inside gridview inside updatepanel按钮单击在更新面板内的gridview内不起作用
【发布时间】:2017-09-08 16:32:14
【问题描述】:

我有一个在更新面板中有一个网格视图的 div,我使用 bootbox.js 来显示模式。 在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>

【问题讨论】:

    标签: c# jquery asp.net gridview


    【解决方案1】:

    模态框的问题是它们通常将内容放在&lt;form&gt; 标记之外。然后按钮不再起作用。

    将按钮替换为链接按钮。他们使用 JavaScript 执行 PostBack,并将在 Modal 中工作。

    【讨论】:

    • 感谢 VDWWD,现在它触发了回发,但 edititemtemplate 中的 asp 文本框仍然没有显示允许我编辑行
    【解决方案2】:

    我没有处理行编辑事件,因此当我在 Firefox 中检查开发人员视图时出现错误。现在它会触发我进行编辑,但它是在第二次单击链接按钮之后才启用编辑。有什么想法吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-25
      • 2018-06-18
      • 1970-01-01
      • 2018-05-05
      • 2014-06-18
      • 2018-08-04
      • 2017-01-06
      • 1970-01-01
      相关资源
      最近更新 更多