0
votes

I have a div that has a gridview inside an updatepanel, that I use bootbox.js to show modal. 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

<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>
2

2 Answers

1
votes

The problem with modals is that they usually place the contents outside of the <form> tag. And then the Buttons do not work anymore.

Replace the Buttons with LinkButtons. They perform a PostBack with JavaScript and will work from a Modal.

0
votes

I wasnt handling rowediting event hence I was getting an error when I checked the developer view in firefox.Now it fires for me to edit but its after the second click of the link button before it enables the editing.Any ideas?