更新面板中的控件不会更新 [英] Controls in update panel don't get updated

查看:116
本文介绍了更新面板中的控件不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UpdatePanel中包含了两个下拉列表.第一个下拉列表包含部门列表.我想要做的是,当用户选择一个部门时,应该在第二个下拉列表中填充员工工作列表在那个特定的部门.

我已经使用了母版页.下拉列表和脚本管理器位于内容页面(子页面)中.在添加母版页之前,此方法非常有效.但是现在,第二个下拉列表(员工列表)仅更新一次.

例如.当我更改部门"下拉列表的默认值时,第二个下拉列表(雇员"列表)将更新.但是,如果我再次更改部门代码,则员工"列表中的值不会得到更新.我使用断点检查了Employee列表中的值.值已更新.但是这些值不会显示在.aspx网页上. (departmentID下拉列表的AutoPostBack属性设置为True)

I have included two Dropdown-lists inside an UpdatePanel. First Dropdown-list contains a list of Departments. What I want to do is, when the user selects a department, the second Dropdown-list should be populated with the list of employees work in that particular department.

I have used an Master page. The Dropdown-lists and the Script Manager are in the content page (child page). This worked Perfectly before I added the Master Page. But now, the second Dropdown-list (Employee list) updates only once.

Eg. when I change the default value of the Departments Dropdown-list, the second Dropdown-list (Employee list) updates. But if I change the Department code again, the values in the Employee list don''t get updated. I checked the values in the Employee list using a break point. There the values have been updated. But the values are not displayed on the .aspx web page. (AutoPostBack property of the departmentID Dropdown-list is set to True)

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <ContentTemplate>
       <asp:DropDownList ID="departmentID" runat="server" onselectedindexchanged="txtCompanyID_SelectedIndexChanged"> </asp:DropDownList>
       <asp:DropDownList ID="employeeID" runat="server"> </asp:DropDownList>
     </ContentTemplate> 
</asp:UpdatePanel>



请帮助我解决这个问题.
提前致谢.祝你有美好的一天!



Please help me with this issue.
Thanks in advance. Have a nice day!

推荐答案

在更新面板中添加以下代码
Add the below code inside your update panel
<Triggers>
<asp:AsyncPostBackTrigger ControlID="departmentID" EventName="SelectedIndexChanged" />
</Triggers>


<asp:DropDownList ID="departmentID" AutoPostback="true" runat="server" onselectedindexchanged="txtCompanyID_SelectedIndexChanged"> </asp:DropDownList>


这篇关于更新面板中的控件不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆