选择的下拉列表在BootStrap模型中不起作用

时间:2019-05-22 17:57:29

标签: jquery bootstrap-4 bootstrap-modal jquery-chosen

我有一个具有下拉列表和两个文本框的引导程序模式。我使用相同的引导模式来添加和编辑记录。当我们添加记录时,将显示下拉列表,而在编辑时则不会显示。下拉列表应始终显示为所选控件。但是它不起作用。下面是我的代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="download.aspx.cs" Inherits="_download" %>
   <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css" rel="stylesheet" type="text/css" /> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.js" type="text/javascript"></script> 

<script language="JavaScript" type="text/javascript">
    $(document).ready(function () {

        $("#btnAttachBenefit").click(function () {
            $("#dropBenefits").show();
            $('#ctl00_ContentPlaceHolder1_txtFname').val('');
            $('#ctl00_ContentPlaceHolder1_txtLName').val('');
        });
    });

    function openPopup(fname, lname) {
        $("#dropBenefits").hide();
        $('#ctl00_ContentPlaceHolder1_txtFname').val(fname);
        $('#ctl00_ContentPlaceHolder1_txtLName').val(lname);
        $('#addModalDates').modal('show');
    }
</script>
   <
     <button type="button" class="inline cboxElement button" data-toggle="modal" data-target="#addModalDates" id="btnAttachBenefit">
                                        Attach Benefit
                                    </button>

<asp:GridView ID="grdUsers" runat="server" Width="100%" CssClass="gridWraper dataTable"
                                         DataKeyNames="pkid" Style="width: 100%; border-collapse: collapse; border-bottom: 1px solid #ababab; border-top: 1px solid #ababab;"
                                        AutoGenerateColumns="false">
                                        <AlternatingRowStyle CssClass="even" />
                                        <Columns>
                                             <asp:TemplateField HeaderText="Edit" HeaderStyle-Width="150px">
                                                        <ItemTemplate>

                                                                <a href="#" class="btn btn-default btn-sm" onclick='openPopup("<%# Eval("FName")%>","<%# Eval("LName")%>")'>Edit</a> 
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                            <asp:BoundField DataField="firstName" HeaderText="First Name" ReadOnly="true" HeaderStyle-CssClass="text-align-left" ItemStyle-CssClass="text-align-left" />
                                            <asp:BoundField DataField="lastName" ReadOnly="true" HeaderText="Last Name" HeaderStyle-CssClass="text-align-left" ItemStyle-CssClass="text-align-left" />
                                        </Columns>
                                    </asp:GridView>
<asp:updatepanel id="UpAddEditBene" runat="server">
<ContentTemplate>
<div class="modal fade" id="addModalDates" tabindex="-1" role="dialog" aria-labelledby="addModalDates">
    <div class="modal-dialog" role="document" style="width: 600px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            </div>
            <div class="modal-body">
                <div>
                    <asp:label id="lblBene" runat="server" style="font-weight: bold; display: block; margin-bottom: 7px">Benefit Name <span style="color: red;">*</span></asp:label>
                    <asp:dropdownlist runat="server" id="dropBenefits" width="555px" cssclass="chosen" appenddatabounditems="false" required>
                                </asp:dropdownlist>
                </div>
                <div style="margin-top: 10px;">
                    <label style="font-weight: bold; display: block;">First Name <span style="color: red;">*</span></label>
                    <asp:textbox runat="server" id="txtFname"></asp:textbox>
                </div>
                <div style="margin-top: 10px;">
                    <label style="font-weight: bold; display: block;">Last Name <span style="color: red;">*</span></label>
                    <asp:textbox runat="server" id="txtLName"></asp:textbox>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <asp:button runat="server" id="Button1" class="btn btn-success" text="Save" onclick="btn_save_Click"></asp:button>
            </div>
        </div>
    </div>
</div>
</ContentTemplate>
 </asp:updatepanel>

任何帮助将不胜感激

0 个答案:

没有答案