Asked by:
Gridview Modal Popup Ok button stops working after Dropdown list inside Gridview event

Question
-
User-173333858 posted
I have a Gridview, row has some textboxes, 1 dropdown list and 2 calendar dates. There is a modal popup that the gridview uses. It succesfully pops up when the user is using onlt TextBox fields. But once the user fills the Dropdown list, in which case a dropdown event is fired, the modal popup does show when the user tries to navigate to a different page, but the 'Ok' button on that popup stops working.The same thing happens with the calendar dropdown selection. I am copying a sample of the code:
---------------------------------------------------------------------------------------------------------------------------
<ContentTemplate><asp:GridView ID="GridVacCov" runat="server" BackColor="white" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"CellSpacing="2" HorizontalAlign="Center" ShowHeaderWhenEmpty="True" EmptyDataText="No data found for given Criteria!"AutoGenerateColumns="False" Width="100%"OnRowEditing="GridVacCov_RowEditing"OnRowCancelingEdit="GridVacCov_OnRowCancelingEdit"OnRowUpdating="GridVacCov_OnRowUpdating"OnRowCreated="GridVacCov_OnRowCreated"ShowFooter="true" FooterStyle-BackColor="White"FooterStyle-BorderColor="Black" OnRowDeleting="GridVacCov_OnRowDeleting" OnRowDataBound="GridVacCov_OnRowDataBound"><FooterStyle BackColor="lightgray" ForeColor="#8C4510" /><HeaderStyle BackColor="#133c70" Font-Bold="True" ForeColor="white" HorizontalAlign="Center"/><PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /><RowStyle BackColor="white" ForeColor="black" HorizontalAlign="Center"/><SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /><SortedAscendingCellStyle BackColor="#FFF1D4" /><SortedAscendingHeaderStyle BackColor="#B95C30" /><SortedDescendingCellStyle BackColor="#F1E5CE" /><SortedDescendingHeaderStyle BackColor="#93451F" /><asp:TemplateField HeaderText="JOBCODE" ItemStyle-Width="5%" Visible ="false"><controlstyle Width="65px"></controlstyle><EditItemTemplate><asp:TextBox ID="TextBox31" max-width="5%" runat="server" Text='<%# Bind("JOBCODE") %>'></asp:TextBox></EditItemTemplate><ItemTemplate><asp:Label ID="Label29" runat="server" Text='<%# Bind("JOBCODE") %>'></asp:Label></ItemTemplate><ItemStyle CssClass="JOBCODE" Width="5%" /></asp:TemplateField><asp:TemplateField HeaderText="ROLE" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Left"><controlstyle Width="10%"></controlstyle><EditItemTemplate><asp:TextBox ID="RoleTextBox31" style="width:90%" runat="server" Text='<%# Bind("RISK_ROLE") %>'></asp:TextBox></EditItemTemplate><ItemTemplate><asp:Label ID="RoleLabel29" runat="server" style="text-align:left; width:10%" Text='<%# Bind("RISK_ROLE") %>'></asp:Label></ItemTemplate><ItemStyle CssClass="ROLE" Width="10%" /><FooterTemplate><asp:DropDownList ID="RiskRoleDropBox" runat="server" AutoPostBack="true"OnSelectedIndexChanged="RiskRoleDropBox_TextChanged" style="width:200px; text-align:center" BackColor="White"></asp:DropDownList> </td><asp:RequiredFieldValidator ID="RoleReq" runat="server" ControlToValidate="RiskRoleDropBox" InitialValue="Choose Risk Role"ErrorMessage="'Role' is a required field." Display="None" ValidationGroup="AddVacGroup" > </asp:RequiredFieldValidator></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="START DATE" ItemStyle-Width="9%"><controlstyle Width="90%"></controlstyle><EditItemTemplate><div class="input-group date"><span class="input-append-addon"><i class="glyphicon glyphicon-calendar"></i></span><p><asp:TextBox ID="TextBox32" min-width="9%" runat="server" CssClass="form-control" Text='<%# Bind("START_DATE", "{0:MM/dd/yyyy}") %>' ValidationGroup="EditVacGroup"></asp:TextBox></p></EditItemTemplate><ItemTemplate><asp:Label ID="Label30" runat="server" Text='<%# Bind("START_DATE", "{0:MM/dd/yyyy}") %>'></asp:Label></ItemTemplate><ItemStyle CssClass="START_DATE" Width="9%" /><FooterTemplate><div class="input-group date"><span class="input-append-addon"><i class="glyphicon glyphicon-calendar"></i></span><p><asp:TextBox ID="StartDtTextBox" min-width="9%" runat="server" CssClass="form-control" Text='<%# Bind("START_DATE", "{0:MM/dd/yyyy}") %>' ValidationGroup="EditVacGroup"></asp:TextBox></p></FooterTemplate></asp:TemplateField></asp:TemplateField></Columns></asp:GridView>---------------------------------------------------------------------------------------------------------
<div id="DivCmnts" runat="server">
<div class="text-center"> You have unsaved changes that will be lost. Please complete operation or click 'Reset/ Cancel' before proceeding.
</div> </div>-------------------------------------------------------------------------------------------------------------------
<script type="text/javascript">
if (some condition) {
var modal = $find("ModalPopupChangeTab");
modal.show(); // $get("").focus();
}
Does anyone know what I am missing ?
RDesh</script>
Thursday, April 30, 2020 5:02 PM
All replies
-
User1535942433 posted
Hi RDesh,
Accroding to your description,I don't understand your reqiurment clearly.Do you have set OkControlID in ModalPopup?
Could you post full codes about front page and behind to us?Besides,you could click 'Edit code sample' and post codes.It will help us to read and solve your problem.
Since you don't post full codes,I create a test:
More details,you could refer to below codes:
<head runat="server"> <title></title> <script src="Scripts/jquery-3.4.1.min.js"></script> <script> $(function () { $("#Button1").on('click', function () { $("#ModalPopupExtender1").show(); }) }) </script> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1" TargetControlID="Button1" OkControlID="Button2"></ajaxToolkit:ModalPopupExtender> <asp:Panel ID="Panel1" runat="server" Style="display: none"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridVacCov" runat="server" ShowFooter="true"> <Columns> <asp:TemplateField HeaderText="JOBCODE" ItemStyle-Width="5%" Visible="false"> <EditItemTemplate> <asp:TextBox ID="TextBox31" max-width="5%" runat="server" Text='<%# Bind("JOBCODE") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label29" runat="server" Text='<%# Bind("JOBCODE") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ROLE" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Left"> <EditItemTemplate> <asp:TextBox ID="RoleTextBox31" Style="width: 90%" runat="server" Text='<%# Bind("RISK_ROLE") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="RoleLabel29" runat="server" Style="text-align: left; width: 10%" Text='<%# Bind("RISK_ROLE") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:DropDownList ID="RiskRoleDropBox" runat="server" Style="width: 200px; text-align: center" BackColor="White" OnSelectedIndexChanged="RiskRoleDropBox_SelectedIndexChanged"> <asp:ListItem Text="A" Value="1" /> <asp:ListItem Text="B" Value="2" /> </asp:DropDownList> <asp:RequiredFieldValidator ID="RoleReq" runat="server" ControlToValidate="RiskRoleDropBox" InitialValue="Choose Risk Role" ErrorMessage="'Role' is a required field." Display="None" ValidationGroup="AddVacGroup"> </asp:RequiredFieldValidator> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="START DATE" ItemStyle-Width="9%"> <EditItemTemplate> <asp:TextBox ID="TextBox32" min-width="9%" runat="server" CssClass="form-control" Text='<%# Bind("START_DATE", "{0:MM/dd/yyyy}") %>' ValidationGroup="EditVacGroup"></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label30" runat="server" Text='<%# Bind("START_DATE", "{0:MM/dd/yyyy}") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox ID="StartDtTextBox" min-width="9%" runat="server" CssClass="form-control" Text='<%# Bind("START_DATE", "{0:MM/dd/yyyy}") %>' ValidationGroup="EditVacGroup"></asp:TextBox> </FooterTemplate> </asp:TemplateField> </Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> <asp:Button ID="Button2" runat="server" Text="Button" /> </asp:Panel> </div> </form> </body>
Code-Behind:
protected void RiskRoleDropBox_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddl = GridVacCov.FooterRow.FindControl("RiskRoleDropBox") as DropDownList; if (ddl != null) { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('success');", true); } }
Best regards,
Yijing Sun
Monday, May 4, 2020 9:30 AM