DropDownList OnSelectedIndexChange不会触发

时间:2012-11-04 17:05:07

标签: javascript asp.net-ajax webforms autopostback

我有两个下拉列表,两个都有AutoPostBack =“true”。 第一个下拉列表包含客户列表,第二个下拉列表包含员工列表。

截图:

My Program

当我在第一个下拉列表中选择一个项目时(在fildset 1“Dados”上),fildset 2“Cliente”必须填充空格(如姓名,邮政编码,地址,电话号码等)。

但是没有发生! 有OnSelectedIndexChange事件和AutoPostBack =“true”但没有任何作用。 但是,当我更改第二个下拉列表“Tecnico”时,第一个下拉列表会消息!

这是我的代码:

<asp:UpdatePanel ID="upGeral" runat="server">
        <ContentTemplate>
            <div >
                <h1>Relatório de Atendimento</h1>
                <br />
                <div>
                    <fieldset style="width: 90%">
                        <legend>Dados</legend>
                        <table>
                            <tr>
                                <td>
                                    <asp:Label Text="Cliente" runat="server" ID="lblCliente"></asp:Label>&nbsp;
                                </td>
                                <td colspan="3">
                                    <asp:DropDownList ID="ddlClientes" runat="server" OnSelectedIndexChanged="ddlClientes_SelectedIndexChanged" AutoPostBack="true">
                                    </asp:DropDownList>
                                    <asp:Label ID="lblIdCliente" runat="server" Height="23px"></asp:Label>
                                </td>
                                <td>
                                    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                                        <ProgressTemplate>
                                            <img src="../Imagens/Icones/ajax-loader.gif" alt="Loading..." />
                                        </ProgressTemplate>
                                    </asp:UpdateProgress>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label runat="server" Text="Responsável" ID="lblResponsavel"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox runat="server" ID="txtResponsavel"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label runat="server" Text="Data Chegada" ID="lblDataChegada"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox runat="server" ID="txtDataChegada" onkeyup="formataData(event);" MaxLength="10"></asp:TextBox>
                                </td>
                                <td class="style3">
                                    <asp:Label runat="server" Text="Hora Chegada" onkeyup="formataHora(event);" MaxLength="5"
                                        ID="lblHoraChegada"></asp:Label>
                                </td>
                                <td class="style4">
                                    <asp:TextBox runat="server" ID="txtHoraChegada" onkeyup="formataHora(event);" MaxLength="5"
                                        Style="margin-left: 0px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label runat="server" Text="Data Saída" ID="lblDataSaida"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox runat="server" ID="txtDataSaida" onkeyup="formataData(event);" MaxLength="10"></asp:TextBox>
                                </td>
                                <td class="style3">
                                    <asp:Label runat="server" Text="Hora Saída" ID="lblHoraSaida"></asp:Label>
                                </td>
                                <td class="style4">
                                    <asp:TextBox runat="server" ID="txtHoraSaida" onkeyup="formataHora(event);" MaxLength="5"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="lblKM" runat="server" Text="KM"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtKM" runat="server" onkeyup="formataInteiro(event);"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="lblTecnico" runat="server" Text="Técnico"></asp:Label>
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlTecnico" runat="server" AutoPostBack="true">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
</ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ddlClientes" />
        </Triggers>
    </asp:UpdatePanel>

我不知道我能做些什么来解决它... 有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试将“UpdateMode”updatePanel属性设置为“Conditional”。